首页 > 其他分享 >vue面试题

vue面试题

时间:2022-10-24 09:13:28浏览次数:38  
标签:面试题 vue keyword search params router push query

 1  methods: {
 2     //搜索按钮的回调
 3     goSearch() {
 4       //路由的跳转,采用的是编程式导航.
 5       //路由传递参数
 6 
 7       //第一种传递query参数
 8       // this.$router.push({path:'/search',query:{keyword:this.keyword}});
 9 
10       //第二种传递params参数 [一定要注意,面试的时候经常问]
11       // this.$router.push({name:'search',params:{keyword:this.keyword}})
12 
13       //第三种传递query+params
14       // this.$router.push({
15       //   name: "search",
16       //   params: { keyword: this.keyword },
17       //   query: { keyword: "ABC" },
18       // });
19 
20       //验证Vue-Router引入Promise技术,最笨的方法,给push传递第二个、第三个参数【回调函数】
21       //下面这种写法:治标不治本!!!!
22       // let result = this.$router.push({name: "search",params: { keyword: this.keyword|| undefined}},()=>{},()=>{});
23 
24       //问题1:push方法,里面this是谁? vueRouter类的实例
25       // this.$router.push({name:'search',params:{keyword:this.keyword}});
26       //问题2:push方法里面的this是谁?windows
27       // let result = this.$router.push;
28       // result({name:'search',params:{keyword:this.keyword}})
29 
30       //点击搜索按钮之前,如果路径当中有query参数,需要携带给search
31 
32       let locations = {
33         name: "search",
34         params: { keyword: this.keyword || undefined },
35       };
36       //确定路径当中有query参数
37       if (this.$route.query.categoryName) {
38         locations.query = this.$route.query;
39       }
40 
41       this.$router.push(locations);
42     },
43     //退出登录的按钮的回调
44     logout(){
45        //派遣action退出登录
46        this.$store.dispatch('logout');
47     }
48   },
49   mounted() {
50     //清除关键字
51     this.$bus.$on("clearKeyword", () => {
52       console.log(123);
53       this.keyword = "";
54     });
55   },
56 };

 

标签:面试题,vue,keyword,search,params,router,push,query
From: https://www.cnblogs.com/hs20011205/p/16820360.html

相关文章

  • [转]VUE 组件的构成
          ......
  • Vue笔记 脚手架vue-cli
                  ......
  • VSCode创建Vue项目
    一、配置环境1.安装VSCode官网下载https://code.visualstudio.com/下载VSCode,按照步骤安装。2.安装node.js(1)官网https://nodejs.org/en/下载node.js,按照步骤安装即......
  • 学习笔记——Vue
    2022-10-21第一个vue.js<!doctypehtml><head><title>Document</title><!--开发环境--><scriptsrc="https://cdn.jsdelivr.net/npm/vue/dist/vue.......
  • Vue+vite+ts+axios+element plus
    一、介绍vueviteTypeScriptScssElementPlusRouteaxiosVuex二、步骤2.1、创建项目使用Vite快速构建项目Vite是一种新型前端构建工具,能够显著提升前端开......
  • Vue2项目ant-design-vue引入报错问题(已解决✔)
    Vue2项目ant-design-vue引入报错问题安装,引入ant-designnpm installant-design-vue--save一直报错:依赖包:解决方法:一直在报错: error in./node_mo......
  • VUE - 视频流直播
    VUE-视频流直播 推流:将直播的内容推送至服务器的过程。拉流:指服务器已有直播内容,用指定地址进行拉取的过程。 本文主要说的是拉流。也就是客户端播放视频流。 ......
  • vdoing主题vuepress的v1版本集成Artalk
    后端部署https://artalk.js.org/guide/backend/install.html#%E4%BD%BF%E7%94%A8-docker使用docker-compose部署即可,很简单。这里需要注意的是配置https。我的部署结......
  • 【Vue】fullcalendar - next ,prev切换回调处理
    如(4条消息)fullcalendar-next,prev等切换月份回调处理_Q.E.D.的博客-CSDN博客_fullcalendarprev这篇博客所说,fullcalendarnext,prev等切换月份的按钮是没有回调函......
  • 1.Vue系列——Vuex
    Note1-Vuex目录Note1-Vuex1.vuex2.关于状态管理3.安装Vuex4.vuex中的一些核心概念4.1vuex中的状态state4.2vuex中的Getter方法4.3vuex中的Mutation4.4vuex中的Actio......