简体   繁体   English

在AXIOS之后更新静态? VUE JS

[英]Update static after AXIOS? VUE JS

I have some problems with vue: 我对vue有一些问题:

i have a list of elements 我有一个元素列表

v-for(item in array) v-for(数组中的项目)

this array i get from Axios (from API) in 我从Axios(从API)获得的数组

created(){} 创建的(){}

part of my script. 我脚本的一部分。 In my template, i have a static variable. 在我的模板中,我有一个静态变量。

{{colors.green[this.number]}} {{colors.green [this.number]}}

And! 和! This static var is not appear after rendering a template (after axios.post). 呈现模板后(在axios.post之后),此静态变量不会出现。 So, i think, i need to update this var or DOM. 所以,我认为,我需要更新此var或DOM。 Or may be there is another way.. What do you think about it? 或者,也许还有另一种方式。。您对此有何看法? Thank you! 谢谢!

UPDATE. UPDATE。 Still cant solve it 仍然无法解决

Params PARAMS

List 名单

DOM DOM

You can't use outside variables in your templates, if you need to use global variable into your template, you would need to wrap it in a data variable. 您不能在模板中使用外部变量,如果需要在模板中使用全局变量,则需要将其包装在data变量中。

{
    data: function(){
        return {
            colors: colors
        };
    }
}

and after that, it should render now. 然后,它应该现在渲染。

Solved. 解决了。 Used a function: 使用的功能:

DOM DOM

Function 功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM