Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Vue.js如何在安装前查看(),can';我不能从手表上得到数据_Javascript_Vue.js_Mount_Watch - Fatal编程技术网

Javascript Vue.js如何在安装前查看(),can';我不能从手表上得到数据

Javascript Vue.js如何在安装前查看(),can';我不能从手表上得到数据,javascript,vue.js,mount,watch,Javascript,Vue.js,Mount,Watch,在async mounted()部分中,它无法从this.point0检索数据,因为它是在监视之前装载的,对吗?我怎样才能解决这个问题 我的目标是在watch中发送新API时更新mounted()中的p1和p0 你可以在这里查看我的代码 从您的代码来看,计算机似乎可以完成这项工作。尝试将逻辑从mounted() computed: { dataPreset() { return [this.p1, this.p2]; } } 每当p1或p2更改时,这将自动返回

async mounted()
部分中,它无法从
this.point0
检索数据,因为它是在监视之前装载的,对吗?我怎样才能解决这个问题

我的目标是在watch中发送新API时更新mounted()中的p1和p0

你可以在这里查看我的代码


从您的代码来看,计算机似乎可以完成这项工作。尝试将逻辑从
mounted()

computed: {
    dataPreset() {
        return [this.p1, this.p2];
    }
 }
每当
p1
p2
更改时,这将自动返回更新的
数据预设

编辑:

据我所知,一旦你在你的观察程序中有了API数据,你肯定可以初始化你的图形。你的观察者可能是

watch: {
    selectedTrend: {
      immediate: true,
      handler(to) {
        this.trend = to.Trends;
        this.GetAPIData(to.Trends, to.DT);  //A method to get the sample API DATA
        this.InitializeGraph(); //A method which initializes your graph
      }
    }
  },

在以下位置创建的示例沙盒:

Im正在呈现挂载下的折线图,因此它可能只在挂载中接收数据集创建。Im不确定,请尝试已计算,但不工作。为什么要在
mounted()
中初始化折线图。只要您准备好数据@Charlie,就可以执行此操作。我觉得你把一个非常简单的问题复杂化了requirement@Charlie您可以在沙盒链接中找到许多改进建议。答案已更新。你能试试看沙盒吗?我真的找不到一个不使用挂载的方式呈现vue js图表的例子
watch: {
    selectedTrend: {
      immediate: true,
      handler(to) {
        this.trend = to.Trends;
        this.GetAPIData(to.Trends, to.DT);  //A method to get the sample API DATA
        this.InitializeGraph(); //A method which initializes your graph
      }
    }
  },