【发布时间】:2019-08-20 10:15:32
【问题描述】:
我有一个v-switch,我希望它是“on/true”,这样开关就在右边,但 v-model 的值仍然是“false”,然后当开关是"off/false" 的 v-model 值为 "true",本质上是反转值。
我正在努力寻找这个选项或如何做到这一点。我正在使用 Vuetify 1.5.15:
<v-switch color="success" prepend-icon="notifications_off" v-model="url.muteNotifications" @click.capture.prevent.stop="togglePolling(url, urlNo)"></v-switch>
【问题讨论】:
-
v-model="!url.muteNotifications"然后切换那个怎么样? -
这有效,直到我点击开关,然后我得到两个错误:
Cannot set reactive property on undefined, null, or primitive value: false和TypeError: Cannot use 'in' operator to search for 'muteNotifications' in false at Proxy.set (commons.app.js:14811)。另外,muteNotifications来自一个对象, -
所以使用计算的:` v-model="someProperty" ... someProperty(){ return !url.muteNotifications } `
-
我不确定它是否会起作用,因为我有一个对象数组,每个对象都包含一个 muteNotification 键,因此在数据中包含一个是行不通的。
标签: vue.js vuejs2 vuetify.js