【发布时间】:2019-08-08 17:01:33
【问题描述】:
我正在创建一个网络应用程序,其中一个对象 property 在单击 inputs.html 页面中的按钮时创建。但是,results.html 需要访问创建的 property 以提示用户将其保存在 firestore 中。
- 我已经尝试过导入和导出变量,但出现此错误:Uncaught SyntaxError: Unexpected token )。
- 我已尝试在 inputs.html 中创建一个 const 变量属性,该属性使用我的脚本进行更改,但我无法在 results.html 中访问它.
- 我还在 results.html 中创建了一个脚本标记,链接到创建 property 的 javascript 文件。
这里是 inputs.js 用于创建 property 并在 inputs.html 中导入。
//create a property and go to results page
document.getElementById("createProperty").addEventListener("click", ()=>{
property= new Property( document.getElementById("address").value, ..., );
window.location = "../Frontend/results.html";
});
}
这是 results.js 中调用 property 并位于 results.html 页面中的代码。
document.getElementById("test").addEventListener("click",(e)=>{
//example of a possible output
console.log(property.address);
});
我希望控制台记录 askprice。但是,收到的错误是:Uncaught ReferenceError: property is not defined。
我想知道可以使用哪些方法来访问这些 javascrip 文件之间的 property。
【问题讨论】:
标签: javascript html