简体   繁体   English

Vue JS 不在 Electron 应用程序内部呈现

[英]Vue JS doesn't render inside of Electron app

I've got an electron app that loads Vue JS 2 from my local machine, however, whatever element I attach my el to completely empties the element and replaces the contents with the Vue JS comment, what am I missing?我有一个 electron 应用程序,它从我的本地计算机加载 Vue JS 2,但是,无论我将el附加到什么元素,都会完全清空该元素并用 Vue JS 注释替换内容,我缺少什么?

index.html index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/css/bulma0.9.2.min.css">
    <link rel="stylesheet" href="./assets/css/tv.css">
  </head>
  <body style="background: white;">
    <div id="app>
      {{ message }}
    </div>
    <script src="./assets/js/vue2.6.12.min.js"></script>
    <script src="./assets/js/tv.js"></script>
  </body>
</html>

tv.js电视.js

new Vue({
  el: '#tv',
  data: {
    message: 'Hello Vue!'
  }
})

This renders nothing, how can I get Vue JS to render?这什么都不渲染,我怎样才能让 Vue JS 渲染?

I think you have a typo in your code, do you mean to use #app instead?我认为您的代码中有错字,您是要改用#app吗?

new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
});

As Zac already stated, there is a typo in your code.正如 Zac 已经说过的,您的代码中有一个错字。 Also there is a missing quote at line 12 ( <div id="app"> ).在第 12 行 ( <div id="app"> ) 处也缺少引号。 I think you have two possibilities.我觉得你有两种可能。 Either you change the id to tv such as:您可以将 id 更改为 tv,例如:

<div id="tv">...</div>

Or, based on Zac's answer, change tv.js to:或者,根据 Zac 的回答,将 tv.js 更改为:

new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
});
- you - without error - 你 - 没有错误

tv.js - example new Vue({ el: '#app', data: { message: 'Hello Vue!' } }) tv.js - 示例 new Vue({ el: '#app', data: { message: 'Hello Vue!' } })

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

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