javascript - How to make a custom function automatically execute when loading in vuejs
PHP中文网
PHP中文网 2017-05-19 10:41:14
0
2
731

For example, if a method is defined in a component:

export default {
  methods: {
    changeIcon () {}
  }
}

How to make the changeIcon function execute automatically?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
左手右手慢动作
export default {
    //这里可以用created或mounted
    mounted() {
        this.changeIcon()
    },
    methods: {
        changeIcon () {}
    }
}
phpcn_u1582

Just call it once in the vue life cycle beforeCreate or Create!
Attached is also a vue life cycle example.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template