0
我正在嘗試使用「Etherson方法」執行一個使用JavaScript創建Web部件的示例。我想單獨.html和.js文件的自定義庫,如下所示: FilesO365 SharePoint CEWP Javascript未加載?
如果我把JS內聯,代碼按預期工作:
<!DOCTYPE html><html><head>
<title></title>
<script type="text/javascript">
$(function() {
$.ajax({
url: "/mOperations/_api/web/lists/GetByTitle('Demo List')/items", type: "GET", headers: { "accept": "application/json;odata=verbose" },
}).success(function (data) {
var listItemInfo = "";
$.each(data.d.results, function (key, value) {
listItemInfo += "<strong>Title: </strong>" + value.Title + " <strong>Description: </strong>" + value.Description + "<br />";
});
$("#divHelloWorld").html(listItemInfo);
});
});
</script></head><body>
<div id="divHelloWorld">Hello World!</div></body></html>
但如果我引用外部.js文件文件,它就像JavaScript不存在(即它不會被調用):
<!DOCTYPE html>
<html">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" scr="https://mysite.sharepoint.com/mOperations/webparts/SimpleExample/SimpleExample.js"></script>
</head>
<body>
<div id="divHelloWorld">Hello Worlds!</div>
</body>
</html>
我驗證路徑https://mysite.sharepoint.com/mOperations/webparts/SimpleExample/SimpleExample.js是正確的。
我錯過了什麼?
你做了谷歌瀏覽器或Internet Explorer(F12)的任何調試,看看在網絡選項卡,以確保將文件加載? – Daniel