gpt4 book ai didi

javascript - npm 安装 angularjs,然后在我的应用程序中需要 angularjs

转载 作者:行者123 更新时间:2023-11-30 09:47:51 25 4
gpt4 key购买 nike

我想做的是非常基础的。我想使用 npm 安装 AngularJS v1.5.x,然后让我可以在我的应用程序中使用它。我在那里看到的所有教程都只是从 angularjs.org 下载 Angular 版本,然后将其包含在他们的 index.html 中。在<script></script>标签。但我想使用 npm 安装 AngularJS,然后让它可供我在我的 index.html 中使用。就像真正的开发人员可能会做的那样!

这是我运行的命令。

$ npm init
$ npm install angular@1.5.7 --save
npm-angular-test@1.0.0 /Users/theDanOtto/Sites/Playground/npm-angular-test
└── angular@1.5.7

这是我的基本 package.json

{
"name": "npm-angular-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"angular": "^1.5.7"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

我创建了一个 index.js ,但我将其留空。然后我在 index.html 中添加了一个 src 标签包括 index.js .

<!DOCTYPE html>
<html ng-app>
<head>
<title>Html</title>
<script src="index.js"></script>
</head>
<body>
<p>My first expression: {{ 5 + 5 }}</p>
</body>
</html>

我的表情只是写{{ 5 + 5 }}而不是 10 .我哪里错了?

最佳答案

通过

包含Angular.js
<script type="text/javascript" src="node_modules/somefile.js"></script>

虽然我使用 bower,但在通过 npm 安装后检查 angularJS 文件是否位于

或使用 requireJS

npm 只是你存储库中前端库的一些管理器,而不是将其包含到 webapp 中

关于javascript - npm 安装 angularjs,然后在我的应用程序中需要 angularjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38064385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com