Vue-cli data data rendering

export default {
    name: "HelloWorld",
    data () {
        return {}
    }
}    

text();

function text(){
    //datamsg
}
May.22,2021

as far as I know, it is not allowed.

because your export default is just a class, not an instantiated VM.
unless this is an instantiated vm, you can. Since your component is not a top-level element, it is recommended to manage it in vuex.

if you are sure you want to do it this way, my advice is this:

// sub-app.js
export default new Vue({
    el: '-sharpsub-app' 
    name: 'HelloWorld',
    data () {
        return {}
    }
})    

// 
import SubApp from '../subApp.vue'
text();

function text(){
    SubApp.$data.msg = 'new msg'
}

what is the scenario of such a requirement?
generally uses data in data in templates.

<template>
    <div>
    {{msg}}
    </div>
</template>

clipboard.png


this event is either the method defined in methods, where you can also operate this.a to access the assignment directly

var vm = new Vue({
  data: { a: 1 },
  methods: {
    plus: function () {
      this.aPP
    }
  }
})
vm.plus()

or the official website: vm.$data

var vm = new Vue({
  data: data
})


vm.a // => 1
vm.$data === data
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31861-2bd83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31861-2bd83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?