vue & arrow function error


  1. <template>
  2. <div class="home">
  3. <img alt="Vue logo" src="../assets/logo.png" />
  4. <!-- <el-button
  5. type="primary"
  6. @click="goTo(`./test-one`)">
  7. goto backToTop page
  8. </el-button> -->
  9. <el-button
  10. type="primary"
  11. @click="goTo(`/test-one`)">
  12. goto backToTop page
  13. </el-button>
  14. <el-button
  15. type="primary"
  16. @click="goTo(`/test-two`)">
  17. goto backTop page
  18. </el-button>
  19. </div>
  20. </template>
  21. <script>
  22. // @ is an alias to /src
  23. // import Tes from '@/components/Test.vue'
  24. export default {
  25. name: "Home",
  26. components: {
  27. // Test,
  28. },
  29. methods: {
  30. // goTo: (path = ``) => {
  31. // console.log(`path =`, path, this);//
  32. // // path = /test-one undefined
  33. // // [Vue warn]: Error in v-on handler: "TypeError: Cannot read property '$router' of undefined"
  34. // this.$router.push(path);
  35. // },
  36. // goTo: function(path = ``) {
  37. // console.log(`path =`, path, this);//
  38. // this.$router.push(path);
  39. // },
  40. goTo(path = ``) {
  41. console.log(`path =`, path, this);//
  42. this.$router.push(path);
  43. },
  44. }
  45. };
  46. </script>

vue router

router-link === a link

router-view === components placeholder


  1. <template>
  2. <div id="app">
  3. <div id="nav">
  4. <router-link to="/">Home</router-link> |
  5. <router-link to="/about">About</router-link>
  6. </div>
  7. <!-- 挂载点 -->
  8. <router-view />
  9. </div>
  10. </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. 2、fork函数与进程ID

    1. fork函数 fork函数用于克隆一份当前的进程资源,调用fork函数之后,进程一分为二,并且两个进程的资源是一样的(只是资源内容完全一样,并不是同一份资源).fork函数的函数原型为:pid_ ...

  2. echarts图表X轴文字过长解决解决方案:根据文字长度自动旋转

    Echarts 标签中文本内容太长的时候怎么办 ? 关于这个问题搜索一下,有很多解决方案.无非就是 省略(间隔显示).旋转文字方向.竖排展示 前面两种解决方案,就是echarts暴露的: {   ax ...

  3. 正则re高级用法

    search 需求:匹配出文章阅读的次数 #coding=utf-8 import re ret = re.search(r"\d+", "阅读次数为 9999" ...

  4. CF42A

    题意 给定两个序列 a 和 b. 序列 a 中的各个数之间的比例可以得出一个 x . 当 b 中比例满足 a 中比例,即 \(b_1\):\(b_2\):\(b_3\)-- \(=\) \(a_1\) ...

  5. FFmpeg libswscale源码分析1-API介绍

    本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/14349382.html libswscale 是 FFmpeg 中完成图像尺寸缩放和像素 ...

  6. 如何使用Conda源快速安装PyTorch?

    数据科学交流群,群号:189158789,欢迎各位对数据科学感兴趣的小伙伴的加入! 1.切换国内源 1.1.在家目录生成.condarc conda config --set show_channel ...

  7. Tomcat 详解URL请求

    这里分析一个实际的请求是如何在Tomcat中被处理的,以及最后是怎么样找到要处理的Servlet的?当我们在浏览器中输入http://hostname:port/contextPath/servlet ...

  8. Spring5源码,@ModelAttribute

    一.什么是@ModelAttribute注解 二.@ModelAttribute注解相关代码详解 一.什么是@ModelAttribute注解 @ModelAttribute注解主要用来将请求转换为使 ...

  9. Poem 01(转)

    Dear Sunshine The way you glow through my blinds in the morning. It makes me feel like you missed me ...

  10. redis防止重复提交

    public interface DistributedLock { boolean getLock(String var1, String var2, int var3);//加锁 void unL ...