双向绑定
作者:
嗯哼_3395 | 来源:发表于
2018-07-07 16:08 被阅读0次<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="vue.js"></script>
</head>
<body>
<div id="box">
<veb :num.sync="num"></veb>
</div>
</body>
<script>
Vue.component("veb",{
props:["num"],
template:"<button @click='change'>{{num}}</button>",
methods:{
change:function(){
this.$emit('update:num',50)
}
}
})
var box=new Vue({
el:"#box",
data:{
num:20,
}
})
</script>
</html>
本文标题:双向绑定
本文链接:https://www.haomeiwen.com/subject/otxguftx.html
网友评论