//main.js
var vm = new Vue({
el: '#test',
components : {
time_ : require('./components/time_.vue'),
},
data: {
// now_date: now_date,
test: "hello world"
},
ready: function(){
console.log("12312");
}
});
//test.html
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="reset.css">
<script src="./build/js/vue.js"></script>
<script src="./build/js/index.js"></script>
</head>
<body>
<!-- <div id="te"> -->
<div id="test">
<time_></time_>
</div>
<!-- </div> -->
</body>
</html>
//time_.vue
<template>
<ul>
<li>{{test}}</li>
</ul>
</template>
<script>
// import time from './src/components/time_.vue'
export default {
data :function(){
return {
test : '',
}
},
ready : function(){
console.log("test");
}
// props :['now_date'],
// computed:{}
}
</script>
用webpack打包。然后出现如下所示错误提示,需要在webpack.config.js里resolve下的alias设置什么吗?还是有什么东西没有设置。
出现错误提示:[Vue warn]: Failed to mount component: template or render function not defined.
(found in root instance)
解决了,在入口文件main.js里面将
import Vue from 'vue'
换成import Vue from 'vue/dist/vue.common.js'
就行了,谢谢大家,手动比拳。详情见此链接