由于props的大小写命名:fatherNum,对应不同的$emit()会有不同的效果,具体如下:
使用.sync修饰符,即
// this.$emit('update:father-num',100); //无效
this.$emit('update:fatherNum',100); //有效
//......
<father v-bind:father-num.sync="test"></father>
与不使用.sync,即
this.$emit('update:father-num',100); //有效
//this.$emit('update:fatherNum',100); // 无效
//......
<father v-bind:father-num="test" v-on:update:father-num="test=$event" ></father>
a.VScode保持vue语法高亮的方式:
1.安装插件:vetur。打开VScode,Ctrl + P 然后输入 ext install vetur 然后回车点安装即可。
2.在 VSCode中使用 Ctrl+Shift+P打开命令面板,输入Preferences: Open Settings(JSON)。
3.在配置对象里加上key和value
1 "emmet.syntaxProfiles": {
2 "vue-html": "html",
3 "vue": "html"
4 }
4.当执行npm run serve时提示的语法错误解决方法:
a.安装npm i prettier -g
b. 根目录建立文件 .prettierrc
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
}
c.相应的文件里格式化代码 alt+shift+f
d. 再重新运行项目
浙公网安备 33010602011771号