[Vuejs]-How to precompile Vue objects in js files?

0👍

I have found a solution, there is no way to directly compile the Vue object in the js file.

But you can extract the template of the Chinese Vue object in index.js into the App.vue file:

<template>
  <div>
    <h1>Hello World.</h1>
  </div>
</template>

index.js imports App.vue.:

import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

new Vue({
    // Load the precompiled template with render .
    render: h => h(App)
}).$mount('#app')

Leave a comment