【发布时间】:2018-05-01 20:18:08
【问题描述】:
我想知道是否有人可以帮助使用 webpack 设置 angularjs,如下所示:https://pastebin.com/dptjwHxp
文件结构如下
root
|____public
| |____index.html
|
|____client
|____________components
| |
|____index.js |_______app.js
我正在尝试“工作”的当前配置(我的意思是让应用组件模板中的内容呈现)如下:
++++ 客户端/index.js
import angular from "angular";
import app from "./components/app";
export default angular.module("practice", []);
++++ 客户端/组件/app.js
import angular from "angular";
export default angular.module("practice", []).component("app", {
template: "<div>This needs to show up!!</div>"
});
++++ public/index.html
<!doctype html>
<html lang="en">
<body ng-app="practice" >
<h1>Angular Practice</h1>
<app></app>
<script src="/bundle.js"></script>
</body>
</html>
有趣的是,如果代码不在其自己的单独组件 app.js 文件中,index.js 如下所示,我可以让应用程序组件渲染得很好:
import angular from "angular";
export default angular.module("practice", []).component("app", {
template: "<div>This needs to show up!!</div>"
});
谢谢。
【问题讨论】: