是否可以将道具从任何js模块传递到vue?
道具对我来说在组件之间传递得很好,但是不是从实际的Vue应用程序本身传递的:
import Vue from 'vue'
import App from './App.vue'
var myVue = new Vue({ export to other files
el: '#entry',
components: {App},
render: h => h(App),
data: function(){
return{
testSuccess:'this test was successful!'
}
},
})
window.myVue = myVue // we use window.myVue becayse if we can export to window, we can export to other js modules.
<template>
<div ref="app">
{{ testSuccess ? testSuccess : 'prop not imported!' }}
</div>
</template>
<script>
export default = {
name: "app",
props: ["testSuccess"]
}
</script>
<div id="entry" >
<app :testSuccess="testSuccess"></app>
</div>
<script src="/dist/build.js"></script>
我想念什么?
我了解如何使用组件执行此操作。
我希望能够将Vue
模块导出到其他js模块并将有意义的信息传递给它。