zoukankan      html  css  js  c++  java
  • Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

    vue项目中遇到

    Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

    页面代码

    <template>
    
        <img src= '../assets/logo.png' />
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="" prop="username">
            <el-input v-model="ruleForm.username"></el-input>
          </el-form-item>
          <el-form-item label="" prop="password">
            <el-input v-model="ruleForm.password"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
          </el-form-item>
        </el-form>
    
    </template>

    解决方法:

    <template>
      <div> // 用div 把代码包裹起来
        <img src= '../assets/logo.png' />
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="" prop="username">
            <el-input v-model="ruleForm.username"></el-input>
          </el-form-item>
          <el-form-item label="" prop="password">
            <el-input v-model="ruleForm.password"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </template>
  • 相关阅读:
    watch 一些实际用法(vue)
    如何动态渲染多个echart图表小结(vue)
    webstorm 合并代码冲突后如何唤起代码合并弹窗方案
    jQuery Mobile
    响应式布局
    Angularjs
    项目经理PPT演讲意见
    创业者自己摸索总结的12条建议
    关于网站建设
    调研方案如何炼成?
  • 原文地址:https://www.cnblogs.com/linsx/p/8526363.html
Copyright © 2011-2022 走看看