手写一个类似于v-for的组件

<div id="result">div>
 mounted() {
   this.nameHeader();
 },
nameHeader() {
  let a = {name: 'age', age: '2'};
  let c = {...a };
  console.log('c', c);
  this.$nextTick(() => {
    var resultElement = document.getElementById("result");
    let arr = [1, 2, 3];
    for (let index = 0; index <= arr.length; index++) {
      var numberSpan = document.createElement("div");
      // 将返回值设置为元素的文本内容
      numberSpan.textContent = arr[index];
      resultElement.appendChild(numberSpan);
      }
  })
},

在这里插入图片描述

你可能感兴趣的:(vue,js,html,css,js,javascript,开发语言,ecmascript)