所以在我的JavaScript遠JavaScript變量,我有這樣的代碼: !/Users/me/Desktop/Screen Shot 2017-07-19 at 2.15.40 PM.png存儲在HTML
@import "MochaJSDelegate.js";
@import 'common.js';
var word = "some kind of file";
function getWord(){
return word;
}
而且我希望能夠在這裏使用「字」,變量在我的html:
<!doctype html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style3.css">
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script>
<script src = "../Sketch/login.js"> </script>
</head>
<body>
<div>
<div class = "title">
Botworx Sketch Plugin
</div>
<div class = "input-login">
<button onclick="displayFormContents(this.form);">Login</button>
</div>
<div class = "input-uploadImages">
<button onclick="displayFormContents(this.form);">Upload Images Only</button>
</div>
<div class = "input-uploadGalleryData">
<button id = "upload-gallery">Upload Gallery Data</button>
</div>
<div class = "input-uploadAll" >
<button id="uploadEverything">Upload Everything</button>
</div>
<input type="file" id="file-chooser" />
<div id="results"></div>
<div id="fb-root"></div>
<button id="upload-button">Upload to S3</button>
</div>
<script>
alert(getWord());
</script>
的亮的行是我參考了JavaScript文件。當我使用標籤並嘗試在html中使用我的函數:「getWord()」時,沒有任何反應。我測試了一下,發現html不喜歡「import」和「@import」這兩個詞。我需要這些關鍵字在我的JavaScript文件中。
我的問題是如何使用@import訪問我的JavaScript文件?
正如上文[如何提問] (https://stackoverflow.com/help/how-to-ask),你應該在代碼中包含你的代碼(不僅僅是代碼的圖片) – alexanderbird
我在代碼中添加了代碼!對於那個很抱歉。 –