How can i pass some variable from the main div folder:
<div
id="app"
someVariable='some value'
></div>
and to have it as a prop in the main App component in VueJS v3.0:
name: "App",
components: {
},
props: {
someVariable: {
type: String,
default: "-"
}
}
You could not access that using props, but you could get the value of that attribute using some Vanilla js DOM like document.getElementById("app").getAttribute("someVariable")
const { createApp } = Vue; const App = { props: ["someVariable"], data() { return { } }, mounted() { console.log(document.getElementById("app").getAttribute("someVariable")) } } const app = createApp(App) app.mount('#app')
<script src="https://unpkg.com/vue@3.0.0-rc.11/dist/vue.global.prod.js"></script> <div id="app" someVariable='some value'> Vue 3 app </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.