直接上油猴脚本代码:
// ==UserScript==
// @name         MyScript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://mysite.com
// @icon         https://www.google.com/s2/favicons?sz=64&domain=vuejs.org
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    // Your code here...
    function myFunc() {
        console.log('myFunc is called!');
    };
    var myButton = document.getElementById('myButton');
    myButton.addEventListener('click', myFunc());
})();
我想要的结果是:等用户点击  myButton 按钮以后才触发 myFunc;
现在的情况是:只要加载页面就会执行 myFunc。
求教各位老哥,该如何修改。我搜了一番下来没找到有帮助的文档。
|  |      1Trim21      2022-03-22 10:59:14 +08:00 via Android  1 myButton.addEventListener('click', myFunc); | 
|  |      3zy445566      2022-03-22 11:23:29 +08:00 😂😂😂 | 
|  |      4wanlei1766      2022-03-22 14:07:41 +08:00 本来想进来学习一番,没曾想一个括号就解决了 。😢 |