我正在瀏覽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