Vuejs:如何在v模型中不使用布尔值

问题描述 投票:0回答:1

我从api获得options.customerdata.showbutton的值为true,所以现在开关是在条件上。我希望开关处于关闭状态,因此应给出v-model =“ false”。但尝试给v-model =“!(options.customerdata.showbutton)”无效,并显示错误。如何实现这一目标?

<b-form-checkbox v-model="options.customerdata.showbutton" name="logo-display" switch >
 </b-form-checkbox>
vue.js v-model
1个回答
1
投票

模型不能为表达式(必须引用属性)

最简单的方法是定义数据并将其设置为负值。

data: {
  return {
    show: !this.options.customerdata.showbutton
  } 
}
© www.soinside.com 2019 - 2024. All rights reserved.