vue爬坑记(雷区,错误点)=> 持续更新
作者:互联网
华丽丽的开篇 => 坑底爬起(想哭又想笑,想笑笑不出……)
—— 回顾过去,展望未来
1、错地不着边际:
Vue.component = ("TodoItem", { //如此优秀的操作你写不出,一支独秀从未被超越 0.0
})
or
正确:
Vue.component("TodoItem", {
})
2 this.$emit方法不能使用驼峰命名的函数
父子组件传值时,this.$emit("handlerDelete",index);父组件监听 @handlerDelete=""; 此时方法不会起效
vue.js:640 [Vue tip]: Event "deleteitem" is emitted in component <TodoItem> but the handler is registered for "deleteItem". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "delete-item" instead of "deleteItem".
解决方案:将驼峰转为小写 handler-delete 或者 handlerdelete
官网示例=> this.$emit('give-advice', this.possibleAdvice[randomAdviceIndex])
标签:坑记,use,vue,TodoItem,component,emit,Vue,雷区,deleteItem 来源: https://www.cnblogs.com/xiaomaotao/p/11423597.html