【问题标题】:Vue not rendering into htmlVue没有渲染成html
【发布时间】:2020-04-22 22:17:54
【问题描述】:

我是 Vue.js 的新手,在将 vue 数据渲染为 html 时遇到问题。

html文件

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue</title>
    <script src="https://unpkg.com/vue@2.6.11/dist/vue.js"></script> 
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div id="app">
        <h1>{{ name }}</h1>
    </div>

    <script src="apps.js"></script>
</body>
</html>

这是 JS 文件:

new VUE({
    el: '#app',
    data: {
        name : 'Dhruv'
    }
});

【问题讨论】:

  • 这是new Vue 不是new VUE
  • 该死....谢谢!

标签: html vue.js vuejs2


【解决方案1】:

作为评论,它是new Vue 而不是new VUE

另外,data 需要返回一个对象。

new Vue({
  el: '#app',
  data: function () {
    return {
        name: 'Dhruv',
    };
  }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-30
    • 2018-08-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2017-02-27
    • 1970-01-01
    • 2021-11-03
    相关资源
    最近更新 更多