【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
目录结构
my-menu-model.js
define('my-menu-model',['vue'],function(Vue){
var myMenuModel = Vue.extend({
template:'<h1>this a menu</h1>'
});
return myMenuModel;
});
config.js
require.config({
baseUrl:"lib",
paths:{
"vue":"vue",
"my-menu-model":"my-menu-model"
}
});
index.js
require(['vue','my-menu-model'],function(vue,myMenuModel){
// //创建组件,并挂在到#app元素上。
new myMenuModel({
el:"#app"
});
});
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="lib/require.js" data-main="lib/config.js"></script>
<script src="index.js"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
来源:oschina
链接:https://my.oschina.net/u/4157150/blog/3149042