繁体   English   中英

Vue 的 @click 功能在 Firefox 中不起作用,但在 Edge、Chrome 中有效

[英]Vue's @click function doesn't work in Firefox but works in Edge,Chrome

 const main = new Vue({ el: '#main', data: { result: "", responseAvailable: false, currentOpen: null }, methods: { fetchData: function(event) { this.responseAvailable = false; fetch("https://restapihost.net/cms", { "method": "GET", "headers": { "Content-Type": 'application/json', 'Authorization': 'Basic cmsdfkKKMNijiweeuiVzdGFwaTpyZXN0YXBp' } }) .then(response => { if(response.ok){ return response.json() } else{ alert("Server returned " + response.status + " : " + response.statusText); } }) .then(response => { this.result = response.data; this.responseAvailable = true; }) .catch(err => { console.log(err); }); } } });
 button { margin-bottom: 1rem; } .content { } .hide { display: none; } .show { display:block; }
 <!DOCTYPE html> <html lang="en"> <head> <!-- Responsive + Encoding Meta Tag --> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Stylesheet --> <link href = "styles.css" rel = "stylesheet"> <!-- Title --> <title>API Call</title> </head> <body> <div id="main"> <h1>API Call Example</h1> <button @click="fetchData">Get Index</button> <div v-if="responseAvailable == true" > <div name="list"> <div v-for="i in result" class="elem"> <p :data-id="i.id" @click="currentOpen=i.id"><i>{{i.title}} </i></p> <div v-bind:class="{'hide':true, 'show':(i.id === currentOpen)}" v-bind:id="i.id" v-html="i.content"></div> </div> </div> </div> </div> </body> <!-- Vue and Custom JavaScript --> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script> <script src = "scripts.js"></script> </html>

按钮上的@click 功能(获取索引)在 Firefox 中不起作用。 我尝试过其他浏览器,如 Chrome 等。它们都运行良好。 Firefox 什么也不做。 我已经测试过 @click="fetchData", @click="fetchData(event)", @click.native="fetchData" 没有任何效果。

谁能解释一下我的 POS 出了什么问题?

发现问题。 代码没问题,没有问题。 Firefox 已经终止了 JS-Engine。 原因我不知道。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM