新人刚开始学习vue,报错Cannot find element: .technologyChinese

新人刚开始学习vue,想让technology_Chinese变量显示 技术,technology_English变量 显示 develop,报错,怎么解决?

import Vue from 'vue/dist/vue.common.js';

<template>
  <div class="title_div">
    <div class="space_div">

    </div>
    <div class="technologyChinese">
      {{technology_Chinese}}
    </div>
    <div class="technologyEnglish">
      {{technology_English}}
    </div>
  </div>

</template>

<script>
  let technologyChinese = new Vue({
    el: '.technologyChinese',
    data: function(){
      return { technology_Chinese: '技术'}
    },
    beforeMount: () => {
      //
    },
    mounted: function () {
      //console.log(li.length)  // 输出5
    },
    methods: {
      getList: function () {
        const _self = this;
        let data = [
          { name: '1', age: '21' },
          { name: '2', age: '22' },
          { name: '3', age: '23' },
          { name: '4', age: '24' },
          { name: '5', age: '25' }
        ];
        _self.$set(_self, 'abc', data);
      }
    }
  })


  let technologyEnglish = new Vue({
    el: '.technologyChinese',
    data: function(){
      return { technology_English: 'develop'}
    },
    beforeMount: () => {
      //
    },
    mounted: function () {
      //console.log(li.length)  // 输出5
    }
  })

</script>


<style src="./assets/styles/index.scss"></style>

图片描述

<template>
  <div class="title_div">
    <div class="space_div">

    </div>
    <div class="technologyChinese">
      {{technology_Chinese}}
    </div>
    <div class="technologyEnglish">
      {{technology_English}}
    </div>
  </div>

</template>

<script>
  import Vue from 'vue/dist/vue.common.js';
  let technologyChinese = new Vue({
    el: '.technologyChinese',
    data: function(){
      return { technology_Chinese: '技术'}
    },
    beforeMount: () => {
      //
    },
    mounted: function () {
      //console.log(li.length)  // 输出5
    },
    methods: {
      getList: function () {
        const _self = this;
        let data = [
          { name: '1', age: '21' },
          { name: '2', age: '22' },
          { name: '3', age: '23' },
          { name: '4', age: '24' },
          { name: '5', age: '25' }
        ];
        _self.$set(_self, 'abc', data);
      }
    }
  })


  let technologyEnglish = new Vue({
    el: '.technologyEnglish',
    data: function(){
      return { technology_English: 'develop'}
    },
    beforeMount: () => {
      //
    },
    mounted: function () {
      //console.log(li.length)  // 输出5
    }
  })
</script>



<style src="./assets/styles/index.scss"></style>

图片描述

阅读 2.1k
2 个回答

import 不放在script里么??

请一步一步的按照官方教程来进行学习,vue的文档已经是少见的清晰了。

https://cn.vuejs.org/v2/guide/

欢迎关注我的微信公众号:前端指南,希望我的回答能帮助到您
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题