Can I get the value of vuex in html?

is there a html file in the vu project? do you want to fetch the data in vuex and put it in title? I can do it with localStorage, but the effect is not good

Jul.24,2021

Yes, if it is a pure html page, remember to introduce various library files, and then instantiate a Vue object object to mount the template, you can take the value of $store.state in html.

<div id="component">
   {{ msg }}
</div>

<script>
new Vue({
  el: '-sharpcomponent',
  data () {
    return {
      msg: $store.state.msg
    }
})
</script>

$store.state.xxx


as long as you can get an instance of vuex's store, you can get any value in store

.
Menu