VUEJS“Vue Hotel Datepicker”组件

时间:2018-01-28 11:42:30

标签: vue.js datepicker vuejs2 vue-component

这是我想在我的index.html上使用[https://krystalcampioni.github.io/vue-hotel-datepicker/] [https://github.com/krystalcampioni/vue-hotel-datepicker#i18n]作为日期选择器的组件,但是我给出了一个错误无法安装组件:模板或渲染功能未定义。以下是我在index.html`

上编写的代码
//index.html
<html>
    <script src="path/to/vue.js"></script> 
    <script src="vue-hotel-datepicker/dist/vue-hotel-datepicker.min.js"></script> 
    <body>
        <div id="app">
            <HotelDatePicker/></<HotelDatePicker>
        </div>
        <script>
            new Vue({
                el: '#app',
                components: { HotelDatePicker }
            })
        </script> 
    </body>
</html>

`

1 个答案:

答案 0 :(得分:0)

如果您使用的是构建工具,则必须在使用vue实例

注册之前导入该组件
import HotelDatePicker from 'vue-hotel-datepicker'

new Vue({
       el: '#app',
       components: { HotelDatePicker }
 })

否则使用require

new Vue({
     el: '#app',
     components: {
          'vue-hotel-datepicker': require('vue-hotel-datepicker')
     }
})