vue & arrow function error


<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png" />
<!-- <el-button
type="primary"
@click="goTo(`./test-one`)">
goto backToTop page
</el-button> -->
<el-button
type="primary"
@click="goTo(`/test-one`)">
goto backToTop page
</el-button>
<el-button
type="primary"
@click="goTo(`/test-two`)">
goto backTop page
</el-button>
</div>
</template> <script>
// @ is an alias to /src
// import Tes from '@/components/Test.vue' export default {
name: "Home",
components: {
// Test,
},
methods: {
// goTo: (path = ``) => {
// console.log(`path =`, path, this);//
// // path = /test-one undefined
// // [Vue warn]: Error in v-on handler: "TypeError: Cannot read property '$router' of undefined"
// this.$router.push(path);
// },
// goTo: function(path = ``) {
// console.log(`path =`, path, this);//
// this.$router.push(path);
// },
goTo(path = ``) {
console.log(`path =`, path, this);//
this.$router.push(path);
},
}
};
</script>

vue router

router-link === a link

router-view === components placeholder


<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<!-- 挂载点 -->
<router-view />
</div>
</template>

refs



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


vue & arrow function error的更多相关文章

  1. vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug

    vue & lifecycle methods & this bug ES6 Arrow function & this bind bug bad fetchTableData ...

  2. vue watch & arrow function bug

    vue watch & arrow function bug watch: { GeoJSON: function(newValue, oldValue) { log(`\n\n\nGeoJS ...

  3. ES6 new syntax of Arrow Function

    Arrow Function.md Arrow Functions The basic syntax of an arrow function is as follows var fn = data ...

  4. 箭头函数 this arrow function 无this

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions import w ...

  5. ES Next & Arrow function & Promise & Iterator & Generator yield & Async Await

    ES Next & Arrow function & Promise & Iterator & Generator yield & Async Await co ...

  6. 廖雪峰js教程笔记5 Arrow Function(箭头函数)

    为什么叫Arrow Function?因为它的定义用的就是一个箭头: x => x * x 上面的箭头函数相当于: function (x) { return x * x; } 箭头函数 阅读: ...

  7. JavaScript学习笔记(十二)——箭头函数(Arrow Function)

    在学习廖雪峰前辈的JavaScript教程中,遇到了一些需要注意的点,因此作为学习笔记列出来,提醒自己注意! 如果大家有需要,欢迎访问前辈的博客https://www.liaoxuefeng.com/ ...

  8. arrow function and bind

    Can you bind arrow functions? https://stackoverflow.com/questions/33308121/can-you-bind-arrow-functi ...

  9. arrow function

    简介 JavaScript 中,函数可以用箭头语法(”=>”)定义,有时候也叫“lambda表达式”.这种语法主要意图是定义轻量级的内联回调函数.例如: // Arrow function: [ ...

随机推荐

  1. 前端中的script标签

    script标签中的重要属性! . 浏览器解析行内脚本的方式决定了它在看到字符串时,会将其当成结束的 标签.想避免这个问题,只需要转义字符"\" ①即可: 要包含外部文件中的 Ja ...

  2. Flutter--Flutter中Widget、App的生命周期

    前言 在App的开发过程中,我们通常都需要了解App以及各个页面的生命周期,方便我们在App进入前台时启动一些任务,在进入后台后暂停一些任务.同时,各个页面的生命周期也很重要,每个页面消失时要做一些内 ...

  3. 7. A typical stream socket session

    http://publibfp.dhe.ibm.com/epubs/pdf/f1a2d400.pdf Read and write data on socket s, using the send() ...

  4. ftp协议服务器与tinyhttp服务demo

    https://www.jianshu.com/p/fb9fcb69efc9 ....... https://www.jianshu.com/p/e9a2e0755496 ============== ...

  5. Vim配置及其他注意事项

    常用的一些配置 set t_ti= set t_te= "这两个比较特殊,后边说 set termencoding=utf-8 set encoding=utf-8 set fileenco ...

  6. win10自带输入法突然变成了繁体

    有可能是在使用Eclipse/MyEclipse的Ctrl + Shift + F进行代码格式化的时候与输入法的热键冲突了

  7. (二)基于shard-jdbc中间件,实现数据分库分表

    基于shard-jdbc中间件,实现数据分库分表 Sharding-JDBC简介 Sharding配置示意图 1.水平分割 1.1 水平分库 1.2 水平分表 2.Shard-jdbc中间件 2.1 ...

  8. 22.firewalld

    1.firewalld 中常用的区域名称及策略规则 2.firewalld-cmd 命令中使用的参数以及作用 与 Linux 系统中其他的防火墙策略配置工具一样,使用firewalld 配置的防火墙策 ...

  9. DEDECMS:修改网站底部出现的POWER BY DEDECMS

    在include/dedesql.classs.php文件中找到第588行: $arrs1 = array(0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0 ...

  10. 将jekyll博客主页的超链接变为新标签页打开

    将jekyll博客主页的超链接变为新标签页打开 最近发现在打开博文查看时往往不想关闭当前页面,想新建一个页面打开,查了HTML资料以后进行修改 在根目录找到index.html,打开编辑,找到图示&l ...