简体   繁体   English

未捕获的引用错误:<function> 使用 Browserify 时未在 HTMLButtonElement.onclick 定义</function>

[英]Uncaught ReferenceError: <function> is not defined at HTMLButtonElement.onclick when use Browserify

I am trying to use MYSQL NodeJS with BROWSERIFY and face this problem我正在尝试将 MYSQL NodeJS 与 BROWSERIFY 一起使用并遇到此问题

HTML code HTML代码

<button type="button" onclick="abc()" >xyz</button>
<script type="text/javascript" src="./bundle.js"></script>

connectdb.js code connectdb.js代码

  function abc(){
   con.connect(function(err) {
   if (err) throw err; 
   con.query("SELECT * FROM database_nmcnpm_nhom1.users", function (err, result) {
   if (err) throw err;
   else
    console.log(result)
  
});});}

I used browserify like this我像这样使用 browserify

browserify./connectdb.js -o./bundle.js browserify./connectdb.js -o./bundle.js

But when i click the button the console show error:但是当我点击按钮时,控制台显示错误:

Uncaught ReferenceError: abc is not defined at HTMLButtonElement.onclick Uncaught ReferenceError: abc is not defined at HTMLButtonElement.onclick

Can someone please suggest a solution?有人可以提出解决方案吗?

Thanks谢谢

Did you include a reference to connectdb.js in your HTML?您是否在 HTML 中包含了对connectdb.js的引用? If not, you'll have to add this to your HTML file:如果没有,您必须将其添加到您的 HTML 文件中:

<script type="text/javascript" src="./connectdb.js"></script>

I generally used to solve this issue as shown below我通常用来解决这个问题,如下所示

<button type="button" (click)="methodName()" > submit</button>

In Angular在 Angular

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的ReferenceError :(函数)未在HTMLButtonElement.onclick中定义 - Uncaught ReferenceError: (function) not defined at HTMLButtonElement.onclick Uncaught ReferenceError: (function) is not defined at HTMLButtonElement.onclick - Uncaught ReferenceError: (function) is not defined at HTMLButtonElement.onclick 未捕获的ReferenceError:在HTMLButtonElement.onclick中未定义函数 - Uncaught ReferenceError: function is not defined at HTMLButtonElement.onclick 得到此错误Uncaught ReferenceError:函数未在HTMLButtonElement.Onclick上定义? - Getting this error Uncaught ReferenceError: function is not defined at HTMLButtonElement.Onclick? ES6模块“Uncaught ReferenceError:函数未在HTMLButtonElement.onclick中定义” - ES6 module “Uncaught ReferenceError: function is not defined at HTMLButtonElement.onclick” Angular 2 和 LeafLet 未捕获的 ReferenceError:<function> 未在 HTMLButtonElement.onclick 中定义 - Angular 2 and LeafLet Uncaught ReferenceError: <function> is not defined at HTMLButtonElement.onclick 未捕获的ReferenceError :(功能)darkmode在HTMLButtonElement.onclick中未定义 - Uncaught ReferenceError: (function) darkmode is not defined at HTMLButtonElement.onclick 未捕获的ReferenceError:未在HTMLButtonElement.onclick中定义查找 - Uncaught ReferenceError: lookup is not defined at HTMLButtonElement.onclick 未捕获的 ReferenceError:showCurrentPage 未在 HTMLButtonElement.onclick 中定义 - Uncaught ReferenceError: showCurrentPage is not defined at HTMLButtonElement.onclick 未捕获的 ReferenceError:在 HTMLButtonElement.onclick 中未定义 postAcmgForm - Uncaught ReferenceError: postAcmgForm is not defined at HTMLButtonElement.onclick
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM