This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.history.pushState(null, null, "#"); | |
window.addEventListener("hashchange", e=> { | |
console.log('Hash 更改後觸發'); | |
}); | |
window.addEventListener("popstate", e=> { | |
window.location.replace('https://medium.com/@Mike_Cheng1208'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// webpack.config.js | |
{ | |
test: /\.(jpe?g|png|gif)$/, | |
use: [{ | |
loader: 'file-loader', | |
options: { | |
name: '[path][name].[ext]' | |
} | |
}] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
data () { | |
return { | |
input: "", | |
num: 1 | |
} | |
}, | |
methods: { | |
handleChange(value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toLowerCase = function(str) { | |
let strarr = str.split(""); // 先把傳入的字串變成陣列 | |
let samtLetterArr = []; // 轉換後的陣列 | |
let samtLetter = ""; // 最後回傳的字串 | |
// 跑回圈去轉換 | |
strarr.forEach(el => { | |
let unicode = el.charCodeAt(0); // 一個個把字串轉成 Unicode | |
let letter = String.fromCharCode(unicode); // 把 Unicode 轉回來字串,塞入 letter | |
if(unicode <= 90 && unicode >=65){ // 但是如果 Unicode 是需要轉換的話 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} str | |
* @return {string} | |
*/ | |
const toLowerCase = function(str) { | |
let strarr = str.split(""); | |
let samtLetterArr = []; | |
let samtLetter = ""; | |
strarr.forEach(el => { | |
let unicode = el.charCodeAt(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { apiArticleItem, apiSearchType } from "api.js"; | |
async function getData() { | |
try { | |
const item = await apiArticleItem(); | |
const type = await apiSearchType(); | |
retrun {item, type} | |
} catch (err) { | |
console.error(err); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//引入api.js 可以確保你網站的來源都是同一個進入點 | |
import { apiUserLogin, apiUserLogout, apiUserSignUp } from "api.js"; | |
apiUserLogin({ | |
email: "mike@gmail.com", | |
password: "123456789" | |
}) | |
.then(res=> { | |
console.log(res); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
// User相關的 api | |
const userRequest = axios.create({ | |
baseURL: 'https://api/user/' | |
}); | |
// 文章相關的 api | |
const articleRequest = axios.create({ | |
baseURL: 'https://api/article/' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
entry: { | |
index: './js/index.js', | |
about: './js/about.js' | |
}, | |
output: { | |
path: path.resolve(__dirname, "./dist"), | |
filename: './js/[name].js', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
test: /\.(sass|scss)$/, | |
use: [ | |
'vue-style-loader', | |
'css-loader', | |
'postcss-loader', | |
{ | |
loader: 'sass-loader', | |
options:{ | |
data: `@import "./src/scss/global/_mixin.scss";` |