我正在浏览w3schools的教程,我复制了他们的片段之一。当我尝试在浏览器中查看页面时,加载需要半分钟。另外,这些功能根本不起作用。这段代码似乎只适用于w3schools。他们提供了cdn(已经过时了,但仍然可以工作)。任何援助非常感谢。Angularjs不工作,页面加载太慢
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<body ng-app="myApp">
<p><a href="#/">Main</a></p>
<a href="#banana">Banana</a>
<a href="#tomato">Tomato</a>
<p>Click on the links to change the content.</p>
<p>The HTML shown in the ng-view directive are written in the template property of the $routeProvider.when method.</p>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
template : "<h1>Main</h1><p>Click on the links to change this content</p>"
})
.when("/banana", {
template : "<h1>Banana</h1><p>Bananas contain around 75% water.</p>"
})
.when("/tomato", {
template : "<h1>Tomato</h1><p>Tomatoes contain around 95% water.</p>"
});
});
</script>
</body>
</html>
只是一个侧面说明我会建议你按照官方的角度网站。他们有一个很好的教程。 – abhishekkannojia
好的。谢谢。 :) – thetekkenmaster
'ngRoute'脚本包含丢失https: – Laazo