[英]Issue Running Browserify to Front End
I've been looking online for a while with no success.我一直在网上寻找一段时间没有成功。 I am not knowledgeable with Browserify or even NodeJS so bare that in mind.我对 Browserify 甚至 NodeJS 都不了解,所以我很清楚。 Around the center of Browserify website, it states that all I need to do is create the function, pack the file with browserify file.js -o output.js, and include as script for the front end.在Browserify网站的中心,它指出我需要做的就是创建函数,使用browserify file.js -o output.js 打包文件,并作为前端脚本包含。
Files I'm translating with browserify (I made the functions in the global space, browserify does not do this from what I've read)我正在用 browserify 翻译的文件(我在全局空间中创建了函数,browserify 没有根据我读过的内容执行此操作)
read:读:
const stateLogic = require('./stateLogic.js');
var x = document.getElementById(exhibit).value
window.read = function()
{
const logic = new stateLogic();
logic.read(x);
alert("executed");
};
write:写:
const stateLogic = require('./stateLogic.js');
var x = document.getElementById("exhibit").value;
var y = document.getElementById("path").value;
window.write = function()
{
const logic = new stateLogic();
logic.append(x, y);
alert("executed");
};
html file (assume all paths are correct) html 文件(假设所有路径都正确)
<body>
<div class="main">
<p class="sign" style="font-family: 'scifi';" align="center">D ° R 3 C T O R ° 3 S</p>
<form class="form1">
<input id = "exhibit" class="un " type="text" align="center" placeholder="Exhibit">
<input id = "path" class="pass" type="text" align="center" placeholder="Directory">
<button type="button" onclick="write()">click</button>
<!--<a class="submit" align="center" onclick="write()">Get Data</a>-->
<p class="forgot" align="center"><a href="#">Aid</p>
</form>
</div>
<script src="js/append1.js"> </script>
<script src="js/control.js"></script>
<script src="js/read1.js"> </script>
</body>
Errors错误
Uncaught TypeError: Path must be a string. Received undefined
at assertPath (append1.js:4626)
at Object.dirname (append1.js:4891)
at Function.load.path (append1.js:12502)
at load (append1.js:12480)
at Object.<anonymous> (append1.js:11785)
at Object.<anonymous> (append1.js:11787)
at Object.77.node-gyp-build (append1.js:11787)
at o (append1.js:1)
at append1.js:1
at Object.<anonymous> (append1.js:11880)
read1.js:4626 Uncaught TypeError: Path must be a string. Received undefined
at assertPath (read1.js:4626)
at Object.dirname (read1.js:4891)
at Function.load.path (read1.js:12502)
at load (read1.js:12480)
at Object.<anonymous> (read1.js:11785)
at Object.<anonymous> (read1.js:11787)
at Object.77.node-gyp-build (read1.js:11787)
at o (read1.js:1)
at read1.js:1
at Object.<anonymous> (read1.js:11880)
Extra info额外信息
Inquiries查询
What am I doing wrong?我究竟做错了什么? And can you explain why my approach is wrong?你能解释为什么我的方法是错误的吗? Thank you for your time :).感谢您的时间 :)。
without testing, because i dont understand what you like to do...没有测试,因为我不明白你喜欢做什么......
read: you wrote:阅读:你写道:
var x = document.getElementById(exhibit).value
The id should be written in ''. id 应该写在 '' 中。
var x = document.getElementById('exhibit').value
Maybe there's the problem也许有问题
BR Patrick BR帕特里克
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.