this.$emit is not a function
来源:4-2 父子组件间的数据传递
 
			SachinYe
2021-05-09

<div id="root">
  <test :value="value" @clickTest="testClick"></test>
</div>
<script>
  var test = {
    props: ["value"],
    template: "<div @click='handleClick'>{{value}}</div>",
    methods: {
      handleClick: function () {
        this.$emit("clickTest", 123);
      },
    },
  };
  var vm = new Vue({
    el: "#root",
    data: {
      value: "测试",
    },
    components: {
      test,
    },
    methods: {
      testClick: (test) => {
        console.log(test);
      },
    },
  });
</script>
写回答
	3回答
- 
				  两年半练习生坤 2023-11-24 this.$emit("clickTest", 123);  不能使用驼峰,要使用“-”进行连接00 不能使用驼峰,要使用“-”进行连接00
- 
				  Dell 2021-05-10 这里也没有报错说is not a function 啊 00
- 
				  Dell 2021-05-09 完整代码截图发给我看一下 062021-05-10
相似问题
 
						