vue中的sync修飾符是一種組件屬性雙向綁定的語法糖。假如有組件1var component1 = {
template:'<div v-show="visible">我是{{title}}</div>', props:['title','visible']
}其中visible要使用sync修飾符<template>
<components1 title="我是title" :visible.sync="visible"></components1></template><script>
export default {
data(){ return { visible:false
}
}
}</script>以上是正常的寫法,那么我現(xiàn)在要用構(gòu)造函數(shù)的形式調(diào)用components1,帶有sync修飾符的屬性應(yīng)該怎么寫var constructor = Vue.extend(component1)var vm = new constructor({
propsData:{
title:'我是title', 'visible.sync':true //這樣寫不對,應(yīng)該怎么寫
}
})為什么踩我問題(手機app可以看到是誰踩了),是我問的太傻b了,還是你們都是大神,不屑于回答這種問題。
1 回答

月關(guān)寶盒
TA貢獻1772條經(jīng)驗 獲得超5個贊
貌似函數(shù)式調(diào)用不能使用語法糖,只能這樣寫
var constructor = Vue.extend(component1)var vm = new constructor({ propsData: { visible: true } })vm.$on('update:visible', v => { vm.visible = v })vm.$mount()this.$el.appendChild(vm.$el)
添加回答
舉報
0/150
提交
取消