Vue.js

【2020面试真题】这15道面试真题,你能答出几道?

蹲街弑〆低调 提交于 2021-01-30 05:54:51
事件起因 含泪忠告:不要在周末没准备的情况下去luo面,不要去luo面,不要去luo面,不要去luo面。一旦被暴击,你的周末和自信心就彻底毁了。 为啥我会这么说?到底咋回事呢?事情是这样的: 这周双休,手机弹出某聘的消息,想着去看看目前前端的概况,就投了简历,然后就开始愉快的玩手机,没一会儿,电话直接来了,问现在方便吗,想简单聊聊,了解一下。我一想,简单聊聊?可以啊,反正才一面,简单聊聊嘛。我就回了个:可以的。没想到,就是这三个字,让我的周末如坐针毡,内心受到了暴击。整个面试过程有的答案似是而非,有的只记得大概,有的直接挠头。到现在,我内心都还平静不下来,也急切的想把题目分享出来,让更多的人看到2020的真实情况。答案没有细细整理,只有思路,语言大家自己组织就好。 来吧,一起来感受下我是如何受到暴击的吧!!! 事件经过 1.JS是一门面向对象的语言,说说面向对象语言的三大特征? 答:这个简单,我自信满满的说:封装、继承、多态。面试官轻声嗯了一下。我的自信心 +1,心想,还行。 2.说说你是如何理解JS中封装、继承这两个特点的? 答:完了,给自己挖了个坑,都是套路。 封装指的是隐藏逻辑实现过程,只对外暴露属性和方法,使用者只需要知道如何使用即可,而不需要关心内部如何实现的,目的在于简化实现过程,做到多处复用,提高开发效率,当需要维护的时候,业务逻辑和工具功能是分开的,降低迭代成本。

基于 Laravel + Vue 构建一个类似 Twitter 的 Web 应用

时光毁灭记忆、已成空白 提交于 2021-01-30 05:48:22
在这一篇示例教程中,我们将会构建一个类似 Twitter 的 Web 应用。我们将使用到 Laravel 和 Vue.js,并且在 Vue.js 中定义一些组件,此外,还会使用 Axios 来发送网络请求。当然,篇幅有限,我们不可能开发一个完整的 Twitter 应用,而是实现一个简化版:用户可以发送 Tweet 并在自己的时间线中看到,可以关注或取消关注其他用户,如果关注了其他用户,那么也可以看到关注用户发布的 Tweet。麻雀虽小,五脏俱全,希望大家可以通过这个简单的应用学会 Laravel 和 Vue.js 的基础用法。 安装配置 Laravel 首先,我们需要安装一个新的 Laravel 应用(也可以通过 Composer 安装,看个人喜好): laravel new laratwitter 进入该项目根目录,安装前端依赖: npm install 接下来,修改 .env 中数据库相关配置符合本地环境,然后通过如下命令生成用户认证脚手架代码: php artisan make :auth 运行如下命令生成相关数据表: php artisan migrate 接下来配置下 Web 服务器(使用 Valet 的话略过),我这里配置的域名是 laratwitter.test ,配置完成后重启下 Web 服务器,然后通过 http://laratwitter.test

一份值得收藏的 Git 异常处理清单

早过忘川 提交于 2021-01-30 03:08:12
前言 Git 作为一种分布式版本控制系统已经成为现在开发的宠儿,不仅应用在前端、后端、客户端等开发场景中,也成为各行业互联网企业分工协作的必备技能之一。 大家在使用过程中总会碰到这样那样的问题,本文主要针对以下经常发生的几种异常情况提供一些解决方案: 本地工作区文件恢复 远程分支删除后,删除本地分支与其关联 修改提交时的备注内容 修改分支名,实现无缝衔接 撤回提交 撤销本地分支合并 恢复误删的本地分支 不确定哪个分支有自己提交的 commit (一)本地工作区文件恢复 大家都知道,一个文件夹中的文件如果被删掉了,那只有在垃圾箱里面找了。如果垃圾箱里面的也被删掉了,以笔者的常识在不借助工具的情况下怕是就找不到了,emmmm。。。 不过,关联了 Git 的文件和文件夹就不一样了,有了本地仓库和远程仓库的双重保护,找到一个被删除的文件也不过就分分钟,一个命令行的事情吧。 语法 : git checkout <filename/dirname> 命令 : git checkout 1.js 这一命令主要用于本地工作区文件的撤回,下图是一个工作区文件被删除后的完美恢复过程。 (二)远程分支删除后,删除本地分支及关联 为方便分支提交,一般情况下会用本地命令 git branch --set-upstream-to=origin/master master 建立本地分支与远程分支的关联,从

How can I have single Vue component and how each contents in that can be routed by buttons of other component

主宰稳场 提交于 2021-01-29 22:41:23
问题 I am new to Vuejs, I am looking to make my code effective just by having one vue component, and i want to specify the routing only once. Currently i have one info.vue in a apps directive and prises.vue & priseshigh.vue in more directive. I want to have just one component in more directive. But the problem is in info.vue i have used two buttons, each button routes to prises.vue & priseshigh.vue respectively. Just like below code: <vs-button class="btn" @click="$router.push({name: 'prises'})

Typescript: class extending Array, can't assign method

孤街醉人 提交于 2021-01-29 20:37:08
问题 I'm working with Typescript and Vue, but I hope that my framework doesn't matter. I'm trying to extend Array like that: class AudioArray extends Array<[number, number]> { constructor(size: number) { super(size); } static fromArray(array: Array<number>): AudioArray { return array.map((v, i) => [i, v]) as AudioArray; } addNumber(num: number): AudioArray { return this.map((x: [number, number]) => [x[0], x[1] + num]) as AudioArray; } } export default AudioArray; and I'm importing it into my

Vue how to watch inner values of json data

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 20:30:12
问题 I have 'd' array in data and I want to watch if its elements gets changed, but some of the elements are nested. My example is basically if I change the value Apple to Axe watcher should execute the methods inside of it, How do I achieve it? <template> <div> <button @click="change">Click me</button> {{ d }} </div> </template> <script> export default { watch: { d: function() { this.hello(); }, }, data() { return { d: [{ a: 'apple' }, { b: 'bananana' }, 'c'], }; }, methods: { hello() { alert(

How to do final state injection with Vue SRR with V8Js

断了今生、忘了曾经 提交于 2021-01-29 19:28:57
问题 The Vue SSR guide is mainly written for running a nodejs server and just touches on using V8Js in the final chapter. It does have a section on final state injection but this doesn't work in the context of V8Js. How can we pass the Vuex state from server to client side when using V8Js? 回答1: First in entry-server.js we need to print not just the app, but also the Vuex state. import { createApp } from './app' new Promise((resolve, reject) => { const { app, router, store } = createApp() router

how to set background image url for local files?

纵然是瞬间 提交于 2021-01-29 19:19:04
问题 I want to paste a relative image url to a div to set it as the background image. Unfortunately the div won't render the image. So this works fine and renders the image <img src="../assets/images/HeroImg.jpg"> but this one doesn't <div style="background-image: url(../assets/images/HeroImg.jpg)"> Content goes here </div> Things I also tried: wrapping the url inside single quotes assets/images/HeroImg.jpg maybe? ./assets/images/HeroImg.jpg starting from the src folder images/HeroImg.jpg and .

vue.v3@0.1.0 serve: `vue-cli-service serve`

荒凉一梦 提交于 2021-01-29 19:09:28
问题 i install bootstarp-vue " npm install bootstarp-vue " , i get a error When i run the project . λ npm run serve > vue.v3@0.1.0 serve G:\vue\vue.v3 > vue-cli-service serve 'vue-cli-service' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue.v3@0.1.0 serve: `vue-cli-service serve` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue.v3@0.1.0 serve script. npm ERR! This is probably not a problem with

Is there a way to shorten defining v-model data, Vue.js and Laravel

徘徊边缘 提交于 2021-01-29 18:28:21
问题 On my edit page of CRUD project, I have a code that fills the form with values of which record is being edited. I use v-model to define HTML inputs, but the code seems too long. I get the data from the prop, and fill the v-model . My code that fills v-model created() { this.studentData = this.student; this.first_name = this.student.first_name; this.last_name = this.student.last_name; this.student_number = this.student.last_name; this.phone_number = this.student.phone_number; this.email = this