search

Home  >  Q&A  >  body text

javascript - Regarding vue life cycle issues, how to obtain rendered elements

Requirements: Get a set of data through axios and display it in the form of a set of <li>. You need to get the actual size of each <li> and then calculate it further. Adjust the style of these <li>.
In beforeMount I use axios to get the data, but in mounted I use $nextTick and still cannot get the rendered $el , please tell me how to obtain the rendered group <li>? Thanks.

怪我咯怪我咯2778 days ago543

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-19 10:34:34

    updated?
    Or, you watch the data variable and then nextTick

    data(){
        return {list:[]}
    },
    mounted(){
        axios.post().then((json) => {
            this.list = json.list
        })
    },
    watch(val){
        this.nextTick(()=>{
            //
        })
    }

    reply
    0
  • Cancelreply