es6过后引入了箭头函数(=>),使用this的时候,无法访问data中的内容。特此记录方法:

<script>
    let vue = new Vue({
        el: "#app",
        data: {
            message: "hello world !"
        },
        methods: {
            fun1: () => {
                let that=vue.$data
                that.message = "everyBody!"
            }
        }
    });
</script>

Logo

前往低代码交流专区

更多推荐