我已经在数据this.coinPairingOptions
中计算了属性,该属性需要根据此schema
中的其他一些字段来呈现其单选按钮。我减少了文件中的代码量以节省空间。
data: function () {
return {
schema: {
{model: "symbolPair", type: "radios", label: "Pair with", values:
this.coinPairingOptions, required: true}
},
computed: {
coinPairingOptions() {
console.log("computing coinPairingOptions")
let coin = this.model.symbol.toUpperCase();
let options = [];
if (this.model.exchange === 'Coinbase') {
options = this.getCoinbasePairs
} else if (this.model.exchange === 'Binance') {
options = this.getBinancePairs
} else {
}
console.log(options.get(coin));
return options.get(coin);
},
}
在开发工具中,我可以看到计算出的属性更改为正确的值,但是数据中未更改。显然,这是适当的行为,但是如何解决呢?我尝试将{{this.coinPairingOptions}}
放在html中,但它出错,因为它是一个最初没有值的计算属性。
任何帮助将不胜感激!
答案 0 :(得分:0)
您不能在<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
中使用london = london[london['Borough'].str.contains('|'.join(east_lon))]
,因为computed property
的评估要早于data
。
您可以使用data
获得预期的结果。看一下documentation,您可以添加参数computed properties
以使用表达式的当前值立即触发回调。
watcher
已在immediate
中访问 Computed properties
。您无需在计算出的内容前放置template
。