vue 组件回调

场景是这样的  


去看下一下的代码  我只说重点  

重点是 tableList.vue 里的    this.$emit("aaa",["11"])  里     aaa 指的是    index.html 绑定的   v-on:aaa  

至于 后面的="a1" 就是你父组件里面的回调方法了


index.html   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>无标题文档</title> 
<link rel="stylesheet" href="../../../../public/admin/css/admin.css" />
</head>  
  
<body>  
<div id="app">
	<tablelist :data='tableData()' v-on:aaa="a1" ></tablelist>
</div>
<script type="text/javascript" src="../../../../public/admin/js/commom/commom.js"></script>
<script type="text/javascript" src="../../../../public/admin/js/demo/index.js"></script>  
</body>  
</html>  

tableList.vue

<template>
	<div class="layui-form">
		{{data}}
	    <table class="layui-table" @click="ok">
		    <thead>
		      <tr>
		        <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
		        <th>人物</th>
		        <th>民族</th>
		        <th>出场时间</th>
		        <th>格言</th>
		      </tr> 
		    </thead>
		    <tbody>
		      <tr>
		        <td><input type="checkbox" name="" lay-skin="primary"></td>
		        <td>11</td>
		        <td>11</td>
		        <td>11-10-14</td>
		        <td>人生似修行</td>
		      </tr>
		    </tbody>
	    </table>
	</div>
</template>

<script>
	module.exports={ 
		props: ['data'],
		methods:{
	    	ok:function(){
		    	alert("1")
		    	this.$emit("aaa",["11"])
		    }
	    }
//		data:function(){ 
//			return { gree:"hello"}
//		}
	}
</script>

<style>
</style>

index.js

//以下是引用控件的方法
import tablelist from '../module/tableList.vue';

new Vue({
	el: '#app',
	components:{
		tablelist
    },
    data:{
    	tableData:function(){
    		return 1
    	}
    },
    methods:{
    	a1:function(res){
    		console.log(res)
    		debugger
    	}
    }
    
    
});   




  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雪狼之夜

打个赏,让博主知道博文没白写

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值