vuex

一年双非本科的大厂面试经历

♀尐吖头ヾ 提交于 2021-01-02 03:52:58
个人情况 毕业于广东某双非大学,校招进入奇安信(前360企业安全)工作,刚刚工作满一年(不好找工作,但人在江湖,身不由己)。 leetcode刷题200+,基本能应付面试了。墙裂建议做做算法题,真的很爽,而且很锻炼编码思维。 富途(offer call) 一面 时长: 47分钟,太久没面试,感觉很多问题没答好,一个小时后居然收到了二面通知,感谢面试官手下留情。 自我介绍 360企业安全,奇安信,360之间的关系?为什么学前端?平时怎么学习的?最近在看什么书吗?... 做题 var a=1 a function fn(a){ a=2; } fn(a); console.log(a); // 1 复制代码 var a={a:1}; function fn(a){ a.a=2; } fn(a); console.log(a.a); // 2 复制代码 a 'use strict'; var a = 1; var obj = { a:2, b:function(){ this.a = 3; }, print:function(){ console.log(this.a); } }; obj.print(); // 2 var print = obj.print; print(); // 报错,严格模式下this默认是undefined 复制代码 function F(){ this.a =

Nuxt.js - The best place for API calls

谁说我不能喝 提交于 2020-12-31 10:55:34
问题 I'm new to Vue.js Nuxt and all front-end stuff. I have a question about API calls. I'm not sure what is the right way, the best practice here. I have a store. In that store, I have actions that are calling my API and sets state eg. async fetchArticle({ state, commit }, uuid) { const response = await this.$axios.get(`articles/${uuid}/`) commit('SET_ARTICLE', response.data) }, And that is fine it is working for one component. But what if I want to just fetch the article and not changing the

Nuxt.js - The best place for API calls

天涯浪子 提交于 2020-12-31 10:55:33
问题 I'm new to Vue.js Nuxt and all front-end stuff. I have a question about API calls. I'm not sure what is the right way, the best practice here. I have a store. In that store, I have actions that are calling my API and sets state eg. async fetchArticle({ state, commit }, uuid) { const response = await this.$axios.get(`articles/${uuid}/`) commit('SET_ARTICLE', response.data) }, And that is fine it is working for one component. But what if I want to just fetch the article and not changing the

How to know a vuex state or a component size in memory

感情迁移 提交于 2020-12-29 12:59:30
问题 Is there a way to find how much size a state (object, array, etc) or a component occupies in memory. In my current context, I need that to know if a specific state/component is very heavy (in term of memory). In chrome, I already tried to snapshot the memory, but I couldn't find how to identify a specific component or state in the result in such large info like this: 来源: https://stackoverflow.com/questions/55476617/how-to-know-a-vuex-state-or-a-component-size-in-memory

Eslint state already declared [Vuex]

╄→гoц情女王★ 提交于 2020-12-29 09:10:34
问题 I am running ESLint and I am currently running into the following ESLint error: error 'state' is already declared in the upper scope no-shadow const state = { date: '', show: false }; const getters = { date: state => state.date, show: state => state.show }; const mutations = { updateDate(state, payload) { state.date = payload.date; }, showDatePicker(state) { state.show = true; } }; export default { state, getters, mutations }; What would be the best way to fix this? 回答1: The best way to fix

How to get Vue Router Params in Vuex?

江枫思渺然 提交于 2020-12-29 06:20:06
问题 I'm not able to use this.$route.params route.params router.params how do I get the params of $route in my actions? 回答1: in your actions.js or store.js import router from 'path/to/router' console.log(router.currentRoute.params) 回答2: You can access the current route through the state or rootState with Vuex. If the action is in a module, use rootState: MY_ACTION: ({rootState}) => new Promise((resolve, reject) => { let params = rootState.route.params // do stuff } If the action is not in a module

How to get Vue Router Params in Vuex?

爱⌒轻易说出口 提交于 2020-12-29 06:19:03
问题 I'm not able to use this.$route.params route.params router.params how do I get the params of $route in my actions? 回答1: in your actions.js or store.js import router from 'path/to/router' console.log(router.currentRoute.params) 回答2: You can access the current route through the state or rootState with Vuex. If the action is in a module, use rootState: MY_ACTION: ({rootState}) => new Promise((resolve, reject) => { let params = rootState.route.params // do stuff } If the action is not in a module

How to get Vue Router Params in Vuex?

我们两清 提交于 2020-12-29 06:19:02
问题 I'm not able to use this.$route.params route.params router.params how do I get the params of $route in my actions? 回答1: in your actions.js or store.js import router from 'path/to/router' console.log(router.currentRoute.params) 回答2: You can access the current route through the state or rootState with Vuex. If the action is in a module, use rootState: MY_ACTION: ({rootState}) => new Promise((resolve, reject) => { let params = rootState.route.params // do stuff } If the action is not in a module

jwt

大兔子大兔子 提交于 2020-12-28 09:44:45
1. JWT是什么 JSON Web Token (JWT),它是目前最流行的跨域身份验证解决方案 2. 为什么使用JWT JWT的精髓在于:“去中心化”,数据是保存在客户端的。 3. JWT的工作原理 1. 是在服务器身份验证之后,将生成一个JSON对象并将其发送回用户,示例如下: {"UserName": "Chongchong","Role": "Admin","Expire": "2018-08-08 20:15:56"} 2. 之后,当用户与服务器通信时,客户在请求中发回JSON对象 3. 为了防止用户篡改数据,服务器将在生成对象时添加签名,并对发回的数据进行验证 4. JWT组成 一个JWT实际上就是一个字符串,它由三部分组成:头部(Header)、载荷(Payload)与签名(signature) JWT结构原理图:见资料“JWT的数据结构.jpg” JWT实际结构:eyJhbGciOiJIUzI1NiJ9. eyJzdWIiOiJ7fSIsImlzcyI6InpraW5nIiwiZXhwIjoxNTYyODUwMjM3LCJpYXQiOjE1NjI4NDg0MzcsImp0aSI6ImM5OWEyMzRmMDc4NzQyZWE4YjlmYThlYmYzY2VhNjBlIiwidXNlcm5hbWUiOiJ6c3MifQ.

Linking to images referenced in vuex store in Vue.js

混江龙づ霸主 提交于 2020-12-25 04:13:16
问题 I am using Vue.js for the first time so apologies if this is a basic question – I have set up the vue project with the vue-cli , vue-router and vuex if this information is helpful. My main issue here is with displaying images or accessing assets. I am able to pull the appropriate data/state in from a data store via a 'getter' and iterate arrays, etc within it (for example, {{student.name}} works perfectly) however when I attempt to display an image with <img :src='student.image'> it fails to