vue & arrow function error
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的更多相关文章
- vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug
vue & lifecycle methods & this bug ES6 Arrow function & this bind bug bad fetchTableData ...
- vue watch & arrow function bug
vue watch & arrow function bug watch: { GeoJSON: function(newValue, oldValue) { log(`\n\n\nGeoJS ...
- ES6 new syntax of Arrow Function
Arrow Function.md Arrow Functions The basic syntax of an arrow function is as follows var fn = data ...
- 箭头函数 this arrow function 无this
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions import w ...
- ES Next & Arrow function & Promise & Iterator & Generator yield & Async Await
ES Next & Arrow function & Promise & Iterator & Generator yield & Async Await co ...
- 廖雪峰js教程笔记5 Arrow Function(箭头函数)
为什么叫Arrow Function?因为它的定义用的就是一个箭头: x => x * x 上面的箭头函数相当于: function (x) { return x * x; } 箭头函数 阅读: ...
- JavaScript学习笔记(十二)——箭头函数(Arrow Function)
在学习廖雪峰前辈的JavaScript教程中,遇到了一些需要注意的点,因此作为学习笔记列出来,提醒自己注意! 如果大家有需要,欢迎访问前辈的博客https://www.liaoxuefeng.com/ ...
- arrow function and bind
Can you bind arrow functions? https://stackoverflow.com/questions/33308121/can-you-bind-arrow-functi ...
- arrow function
简介 JavaScript 中,函数可以用箭头语法(”=>”)定义,有时候也叫“lambda表达式”.这种语法主要意图是定义轻量级的内联回调函数.例如: // Arrow function: [ ...
随机推荐
- 2、fork函数与进程ID
1. fork函数 fork函数用于克隆一份当前的进程资源,调用fork函数之后,进程一分为二,并且两个进程的资源是一样的(只是资源内容完全一样,并不是同一份资源).fork函数的函数原型为:pid_ ...
- echarts图表X轴文字过长解决解决方案:根据文字长度自动旋转
Echarts 标签中文本内容太长的时候怎么办 ? 关于这个问题搜索一下,有很多解决方案.无非就是 省略(间隔显示).旋转文字方向.竖排展示 前面两种解决方案,就是echarts暴露的: { ax ...
- 正则re高级用法
search 需求:匹配出文章阅读的次数 #coding=utf-8 import re ret = re.search(r"\d+", "阅读次数为 9999" ...
- CF42A
题意 给定两个序列 a 和 b. 序列 a 中的各个数之间的比例可以得出一个 x . 当 b 中比例满足 a 中比例,即 \(b_1\):\(b_2\):\(b_3\)-- \(=\) \(a_1\) ...
- FFmpeg libswscale源码分析1-API介绍
本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/14349382.html libswscale 是 FFmpeg 中完成图像尺寸缩放和像素 ...
- 如何使用Conda源快速安装PyTorch?
数据科学交流群,群号:189158789,欢迎各位对数据科学感兴趣的小伙伴的加入! 1.切换国内源 1.1.在家目录生成.condarc conda config --set show_channel ...
- Tomcat 详解URL请求
这里分析一个实际的请求是如何在Tomcat中被处理的,以及最后是怎么样找到要处理的Servlet的?当我们在浏览器中输入http://hostname:port/contextPath/servlet ...
- Spring5源码,@ModelAttribute
一.什么是@ModelAttribute注解 二.@ModelAttribute注解相关代码详解 一.什么是@ModelAttribute注解 @ModelAttribute注解主要用来将请求转换为使 ...
- Poem 01(转)
Dear Sunshine The way you glow through my blinds in the morning. It makes me feel like you missed me ...
- redis防止重复提交
public interface DistributedLock { boolean getLock(String var1, String var2, int var3);//加锁 void unL ...