我有一个很长的外部JS文件,我想把它分成两个独立的JS文件。这样做的问题是,file_1.js不再了解file_2.js的功能。有没有什么特别的事情是我在做这个的时候没有想到的。
<script src="js/file_1.js"></script>
<script src="js/file_2.js"></script>
我的html的头。
我已经准备好加载文档中的所有内容了。
$(function() { some code in both });
干杯
我有一个调用外部js文件的html文件。我假设html文件不能识别
外部js文件,因为firebug抛出错误'myfunction() is not defined‘。
这是我在外部js文件中的代码。
function a(){
//just function
}
这是一个制造麻烦的html文件。
<script type="javascript/text" src="./myjs.js"></script>
<script>
a();
</script>
谁能告诉我为什么我不能实现
我需要为当前项目编写和管理大量的JavaScript代码。
我主要根据模块将它们分成多个.js文件。
所以,现在我有一个例子:
Map.js // deal with google map issue
Common.js // common functions that will share by all modules
User.js // user module js code
Geofence.js // geofence module js code
etc.....
例如,在我的User.js文件中
如果我想声明一个仅在User.js文件内部使用的函数,而不能被外部访问,该怎么办?我
假设我的Firebase应用程序在我的functions文件夹中有以下结构。
functions
> node_modules // INSTALLED NODE MODULES
> distApp // REACT APP FILES TRANSPILED WITH BABEL
App.js
index.html
> distFunctions // FUNCTION FILES TRANSPILED WITH BABEL
function1.js // SOME OF THEM U
我遵循关于如何使用文档中的组件的指导,但是我得到了TypeError: show is not a function
在我的主要JS文件(app.js)中,我使用npm添加了以下内容并添加到我的项目中
import VModal from 'vue-js-modal'
Vue.use(VModal)
文档指出,我现在可以从应用程序的任何位置调用一个模式,因此我创建了一个特定于页面的JS文件,并包含了以下内容,以在包含vue、app.js和页面特定profile.js文件的页面上隐藏/显示一个带有profile.js的模式。
export default {
method
当我在下拉框中选择一项时,history.js中包含的Javascript函数不会在Struts2jsp页面中被调用。 这是我在开发人员工具中看到的错误 Uncaught ReferenceError: getClasses is not defined
at HTMLSelectElement.onchange (history.action:279) 这是如何包含在jsp页面中的。 <%@ taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<%@ taglib uri="
在文件data.js中,我有:
(function () {
data()
function runThisWhenDataIsFinished() {
console.log("Works!");
}
})();
在我拥有的文件app.js中
function data() {
console.log("Im in the data function");
runThisWhenDataIsFinished();
}
当我调用data()时,我得到消息"Im in the data
我有一个父类文件A.js和一个子类文件B.js
//A.js
class A {
constructor(){
console.log(__filename)
}
}
//B.js
class B extends A {
constructor() {
super();
}
}
new B()
//will output A.js
有没有办法在a.js中获取B.js路径?
所以我知道这个问题已经问过很多次了,但我似乎无法做到这一点,尽管在我看来它是正确的。来自外部文件的jquery函数没有正确加载。
我的tableMethods.js外部文件看起来像
$(function(){
// Write FITS
function writeFits(){
var data = $('.sastable').bootstrapTable('getData');
var name = $('#fitsname').val();
$.getJSON($SCRIPT_ROOT + '/write