0
我正在致力于javascript/vue.js页面at this link。我将此代码添加到上面的文件:
$(document).ready(function() {
myIP();
});
function myIP() {
$.getJSON("//freegeoip.net/json/?callback=?", function(data) {
// after succesful ajax response call myCallback with data.ip
myCallback(data.ip);
});
}
function myCallback(theIP) {
// do your stuff here
console.log("Data.ip:", theIP);
configDefault.lex.sessionAttributes.ip = theIP;
//console.log("ConfigDefault:", configDefault);
};
当我加载网页我看$ sign undefined
错误。然后我加入<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
但后来我开始错误
Uncaught Error: Module build failed: SyntaxError: Unexpected token (34:0)
32 |
33 |
> 34 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|^
35 |
36 | // TODO turn this into a class
有一件事我注意到,有在上面的链接没有<head>
部分的文件中,最上SO提到所示的解决方案就摆在<head>
jQuery的链接部分。
我需要做些什么来解决这个问题?