vscode & element-ui-table-template-scope warning

<el-table :data="list">
  <el-table-column label="静态内容">
    <template scope="scope">
      static content
    </template>
  </el-table-column>
  ...
</el-table>

上面这段代码在 vscode 编辑器中会出现错误提示, 如图:

image.png

解决办法是把 scope="scope" 改为 scope="{}", 如图:

<el-table :data="list">
  <el-table-column label="静态内容">
    <template scope="{}">
      static content
    </template>
  </el-table-column>
  ...
</el-table>

注意: 如果把 scope="{}" 写成 scope="", vscode 倒是不报警告了, 但经测试发现内容不会被渲染, 所以一定要这样写: scope="{}"

参考: https://github.com/vuejs/eslint-plugin-vue/issues/781

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。