首页 > 解决方案 > 将变量传递给 vue 中的 props 选项

问题描述

我正在使用这个插件在我的网站中嵌入交易视图图表

以下是我的代码:

<div class="chart">
  <template>
    <div class="hello">
      <VueTradingView style="height: 250px;" :options="{
          autosize: true,
          symbol: [this.tvmarket],
          interval: '15',
          timezone: 'Asia/Singapore',
          theme: 'dark',
          toolbar_bg: '#f1f3f6',
          enable_publishing: false,
          hide_side_toolbar: false,
          allow_symbol_change: true,
          show_popup_button: true,
        }" />
      </div>
  </template>
</div>

该页面偶尔不会加载正确的符号。有时它可以解析变量“BINANCE:BTCUSDT”,但有时不能。如何正确地将变量传递给选项?

标签: vue.js

解决方案


尝试这个

<div class="chart">
  <template>
    <div class="hello">
      <VueTradingView style="height: 250px;" :options="{
          autosize: true,
          symbol: tvmarket,
          interval: '15',
          timezone: 'Asia/Singapore',
          theme: 'dark',
          toolbar_bg: '#f1f3f6',
          enable_publishing: false,
          hide_side_toolbar: false,
          allow_symbol_change: true,
          show_popup_button: true,
        }" />
      </div>
  </template>
</div>

推荐阅读