Vue js, vue-element-ui 使用总结

#1 报错
plat_users.html:385 Uncaught TypeError: Cannot read property 'validate' of undefined
    at VueComponent.submitForm (plat_users.html:385)
    at Proxy.boundFn (vue.js:130)
    at click (eval at makeFunction (vue.js:8480), <anonymous>:2:5611)
    at VueComponent.invoker (vue.js:1948)
    at VueComponent.Vue.$emit (vue.js:2549)
    at VueComponent.handleClick (element-ui.js:3)
    at boundFn (vue.js:130)
    at HTMLButtonElement.invoker (vue.js:1948

原因是 @click="submitForm(reviseForm)" 中的 reviseForm 没有使用引号。

正确代码,如下:

<el-button type="primary" @click="submitForm('reviseForm')">确 定</el-button>

# 闭包中 return,并无法中断外面的代码执行。
Vue js:
 
    this.$refs[formName].validate(function (valid) {
                    
                    if (!valid) {
                        return ; // 此处的 return 无法中断下面发起的 http post 请求。
                    }
                });
                
    // 上面闭包代码中的 return 并无法中断下面的请求
    this.$http.post('url', {username: 'james', 'pwd': 'james'}).then(function(res) {
        
    })
# issue -4: vue-element-ui 中的 pagination,选中的展示条数,无法获取到选中状态。

-- View --
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" 
:current-page="currentPage" :page-sizes="[10, 20, 30, 40]"
 :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" 
:total="total" class="pagination"></el-pagination>
  
-- Vue js --  
handleSizeChange: function (val) {
            var _this = this;
             this.$http.post('/user/index', {current: this.currentPage, size: val}).then(
              function (response) {
                    _this.paginate_res = response.body;
                    _this.tableData3 = response.body.data.users;
                    _this.total = response.body.data.total;
                    _this.pageSize = parseInt(response.body.data.size);

                }, function (response) {
                    this.$notify({
                        title: '网络响应缓慢',
                        message: '网络暂无响应,请稍后再试。=.=',
                        type: 'info'
                    });
                });
}

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

推荐阅读更多精彩内容

  • 下载安装搭建环境 可以选npm安装,或者简单下载一个开发版的vue.js文件 浏览器打开加载有vue的文档时,控制...
    冥冥2017阅读 6,081评论 0 42
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,886评论 18 139
  • vue在最近一段时间火热起来,相比较于ng特别是ng1和rectjs, vue显得更加轻,它也迎合了前端模块化,组...
    拿着号码牌徘徊阅读 5,039评论 4 43
  • 很多年前买来了这个版本的人间词话,近期细看了一下,结果发现编写得很差,更恐怖的是错漏很多,如果不是正品书店购买的,...
    胡乱色彩阅读 535评论 0 0
  • 现在,我会想,当我要给你看这文字时,是已经到了要说再见,还是不得不告别的时候? 纵使相爱也终有必须割舍的理由,可要...
    river123456阅读 330评论 0 0