javascript - How to use Vue to write a component and only use it on some traditional html pages?
为情所困
为情所困 2017-06-12 09:28:18
0
2
713

1 Existing component written using vue example
2 If registered globally in app.js, any html page can be used normally
3 But if this component is only used on one page, how to Register this component locally on this page?

为情所困
为情所困

reply all(2)
某草草

Just instantiate vue in your traditional page, introduce your component, and register it in the currently instantiated vue

var Child = {
  template: '<p>A custom component!</p>'
}
new Vue({
  // ...
  components: {
    // <my-component> 将只在父模板可用
    'my-component': Child
  }
})
習慣沉默

You need to read the Vue documentation 3~4 times and register locally

import YourComponent from 'your-component';
export default{
    components: { YourComponent }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template