element icon indicating copy to clipboard operation
element copied to clipboard

通过标签全局引入,render时data和methods的属性全找不到

Open x73x63 opened this issue 10 years ago • 1 comments

Vue :2.0.0-rc.6 Element ui :1.0.0-rc.4

<!-- 引入样式 -->
<link rel="stylesheet" href="//unpkg.com/[email protected]/lib/theme-default/index.css">

<!-- body -->
<div id="app"></div>

<!-- 引入组件库 -->
<script src="//unpkg.com/[email protected]/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>

<script>
var Main = {
  template: `
    <el-upload
      action="http://jsonplaceholder.typicode.com/"
      :on-preview="handlePreview"
      :on-remove="handleRemove">
      <el-button size="small" type="primary">点击上传</el-button>
      <div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过500kb</div>
    </el-upload>
  `
};
new Vue({
    el: '#app',
    methods: {
        handleRemove(file, fileList) {
            console.log(file, fileList);
        },
        handlePreview(file) {
            console.log(file);
        }
    },
    render: h => h(Main)
})
</script>

报错:

[Vue warn]: Property or method "handlePreview" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in anonymous component - use the "name" option for better debugging messages.)
[Vue warn]: Property or method "handleRemove" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in anonymous component - use the "name" option for better debugging messages.)

x73x63 avatar Sep 30 '16 20:09 x73x63

什么鬼,看清楚 methods 放在哪

QingWei-Li avatar Sep 30 '16 22:09 QingWei-Li