childComponent组件child-component.vue:
<template>
<div id="child-template">
<input type="text" v-model="msg">
<button @click="notify">Dispatch Event</button>
<slot>回退</slot>
</div>
</template>
<script>
export default {
data(){
return {msg:'hello'};
},
methods:{
notify(){
if(this.msg.trim()){
console.log(this.msg);
this.msg = '';
}
}
}
}
</script>
入口js文件:
import Vue from 'vue';
import childComponent from './child-component.vue';
var vm = new Vue({
el: '#app',
data:{
name:'laoqiren'
},
components:{
childComponent
}
});
index.html:
<div id="app">
<child-component></child-component>
</div>
浏览器报错:
Uncaught TypeError: Cannot read property 'indexOf' of undefined
请问这是怎么回事呢?谢谢
demo 不谢 https://github.com/TIGERB/eas...