vue 访问模板中的导入变量

Chr*_*ris 7 vue.js vue-class-components

是否有某种方法可以在模板中使用导入的对象,而无需在 vue 组件中为其指定别名/属性。即我可以以某种方式使用未在“this”上定义的变量

 <template>
        <div v-if="Store.loaded"></div> //Store not defined on component
        <div v-if="store.loaded"></div> //works
    </template>

    <script>
        import Vue from 'vue'
        import { Component } from 'vue-property-decorator'
        import Store from "../store" // can I somehow use this directly?

        @Component
        export default class App extends Vue {
            store = Store // is there some way so I don't need this line?
        }
    </script>
Run Code Online (Sandbox Code Playgroud)

Bsa*_*lex 1

您可以使用插件,就像vuex那样。但一般来说,这是一个坏主意。
它使使用您的代码的其他人质疑Store字段的来源。