
正文
Vue 一些零零散散~
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
1. F5刷新不会触发vue的destroyed事件.
2. computed 的 vuex 数据 ------> beforeCreated: undefined / created: 有数据.
3. vue打包后会产生map文件. map文件作用是打包后还能精准定位代码错误位置 . 取消方法 ------> /config/index.js / productionSourceMap:false .
4. vue中input框监听回车键 -------> @keyup.enter="fn()" .
5. vue中input自动聚焦
directives: {
focus: {
inserted: function (el) {
el.focus()
}
}
}
<input v-focus />
6. vuex 的 v-model 双向数据绑定
computed: {
getVal: {
get() {
return this.$store.state.val
},
set(newVal) {
this.$store.commit('handleVal', newVal)
}
}
}
<input v-model="getVal" />
7. computed 属性不能修改, 如果需要在computed属性的基础上修改数据, 在created中赋值给data, 然后维护data;
8. vue-cli 在ie上打不开的问题, npm i babel-polyfill -D , 在main.js中引入 Import "babel-polyfill" , 在build/webpack.base.conf.js中, entry : ["babel-polyfill",'./src/main.js'] 搞定!!
9. nuxt.js 苹果跳路由用params传参数传不过来, 用query传







