简体   繁体   中英

Update static after AXIOS? VUE JS

I have some problems with vue:

i have a list of elements

v-for(item in array)

this array i get from Axios (from API) in

created(){}

part of my script. In my template, i have a static variable.

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

And! This static var is not appear after rendering a template (after axios.post). So, i think, i need to update this var or DOM. Or may be there is another way.. What do you think about it? Thank you!

UPDATE. Still cant solve it

Params

List

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: function(){
        return {
            colors: colors
        };
    }
}

and after that, it should render now.

Solved. Used a function:

DOM

Function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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