Web前端最全网易云音乐移动端项目实战(分解中),2024年最新面试题参考答案

总结

大厂面试问深度,小厂面试问广度,如果有同学想进大厂深造一定要有一个方向精通的惊艳到面试官,还要平时遇到问题后思考一下问题的本质,找方法解决是一个方面,看到问题本质是另一个方面。还有大家一定要有目标,我在很久之前就想着以后一定要去大厂,然后默默努力,每天看一些大佬们的文章,总是觉得只有再学深入一点才有机会,所以才有恒心一直学下去。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

color: #e6e6e6;

}

.play {

margin-right: 0.1rem;

font-size: 0.64rem;

}

.menu {

font-size: 0.7rem;

}

}

}

}

playMusics.vue

1.基本布局

2.z-index属性

3.跑码灯marquee使用

4.从子组件@click="$emit('back')修改父组件数据@back="showpage=!showpage"

5.在行内样式直接引用变量:src="playdetail.al.picUrl"

//文本中引用 style=“{backgroundImage=url(”“)}”

:style=“{backgroundImage:url(${playdetail.al.picUrl})}”

<svg class=“icon” aria-hidden=“true” @click=“$emit(‘back’)”>

{{playdetail.al.name}}

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent”>

import { createStore } from ‘vuex’

export default createStore({

state: {

playlist:[{

id:138164304,

name:“不会再爱你了3.0”,

al:{

id:138164304,

name:“不会再爱你了3.0”,

pic:109951166868365440,

picUrl:“http://p4.music.126.net/ajXo6RG2aM8I5yYJuPmUrQ==/109951166868365438.jpg”

}}],

playlistindex:0

},

mutations: {

changeplaylist:function(state,value){

state.playlist = value;

},

setPlayindex:function(state,indexvalue){

state.playlistindex = indexvalue

}

},

actions: {//异步获取数据然后修改对应方法

},

modules: {

}

})

dispatch:含有异步操作,例如向后台提交数据,写法: this.$store.dispatch(‘action方法名’,值)

commit:同步操作,写法:this.$store.commit(‘mutations方法名’,值)

mutations:

1、通过提交commit改变数据

2、只是一个单纯的函数

3、不要使用异步操作,异步操作会导致变量不能追踪。也就是说,用action中的函数调用mutations中的函数,进行异步操作state中的数据

在这里插入图片描述

五、获取歌词内容解析

1.找到获取歌词的api,ajax请求数据,获取对应id值的歌词详情

2.对歌词进行正则匹配,传递到store库中

播放全部
(共{{playlist.tracks.length}}首)
+收藏({{playlist.subscribedCount}})
{{i+1}}
{{item.name}}

{{item}}

{{item.al.name}}

store下的index.js

import { createStore } from “vuex”;

export default createStore({

state: {

playlist: [

{

id: 138164304,

name: “不会再爱你了3.0”,

al: {

id: 138164304,

name: “不会再爱你了3.0”,

pic: 109951166868365440,

picUrl:

“http://p4.music.126.net/ajXo6RG2aM8I5yYJuPmUrQ==/109951166868365438.jpg”

}

}

],

playlistindex: 0,

lyric: “”

},

getters: {

lyricContentFn: function(state) {

//split 把一个字符串分割成字符串数组

//slice 方法选取基于索引的元素的子集

let arr = state.lyric.split(/\n/igs).map((item, i) => {

var min = item.slice(1, 3);

var sec = item.slice(4, 6);

var mil = item.slice(8, 10);

var text = item.slice(11, item.length);

var time = parseInt(mil) + parseInt(sec)*1000 + parseInt(min)100060;

return {

time,

min,

mil,

sec,

lyric:text,

item

};

});

console.log(arr);

return arr;

}

},

mutations: {

changeplaylist: function(state, value) {

state.playlist = value;

},

setPlayindex: function(state, indexvalue) {

state.playlistindex = indexvalue;

},

setLyric(state, value) {

state.lyric = value;

}

},

actions: {

//异步获取数据然后修改对应方法

async reLyric(content, playload) {

content.commit(“setLyric”, playload);

}

},

modules: {}

});

playMusics.vue

<svg class=“icon” aria-hidden=“true” @click=“$emit(‘back’)”>

{{playdetail.al.name}}

{{item.lyric}}

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent”>

api下的index.js

import axios from ‘axios’;

//获取轮播图API

/*

0: pc

1: android

2: iphone

3: ipad

*/

let localhostUrl = ‘http://localhost:3000’

export async function ff(type = 2) {

return await axios.get(${localhostUrl}/banner?type=${type});

}

//获取推荐歌单默认十条数据

export function getMusicList(limit = 10){

return axios.get(${localhostUrl}/personalized?limit=${limit})

}

//获取歌单的详情

export async function getMusicContent(id){

return await axios.get(${localhostUrl}/playlist/detail?id=${id})

}

//获取歌词的内容

export async function getLyric(id){

return await axios.get(${localhostUrl}/lyric?id=${id})

}

网速有点慢emmmm

在这里插入图片描述

六、歌词根据时间滚动

1.定义一个函数用于获取请求歌词对应的时间信息,并且找出当前所在歌词的播放时间点,以及当前歌词的内容项

2.在dom元素中循环出得到的数组输出对应的歌词,并且有条件是否当前给定activecolor:red样式。根据当前audio属性中有currentTime的值还有获取每一句歌词的播放事件点,以及播放前一个时间点做判断语句。让其发生样式的修改。

在这里插入图片描述

在这里插入图片描述

store下的index.js

import { createStore } from “vuex”;

export default createStore({

state: {

playlist: [

{

id: 138164304,

name: “不会再爱你了3.0”,

al: {

id: 138164304,

name: “不会再爱你了3.0”,

pic: 109951166868365440,

picUrl:

“http://p4.music.126.net/ajXo6RG2aM8I5yYJuPmUrQ==/109951166868365438.jpg”

}

}

],

playlistindex: 0,

lyric: “”,

currentTime: 0,

id:0

},

getters: {

lyricContentFn: function(state) {

//split 把一个字符串分割成字符串数组

//slice 方法选取基于索引的元素的子集

let arr = state.lyric.split(/\n/gis).map((item, i, arr) => {

var min = parseInt(item.slice(1, 3));

var sec = parseInt(item.slice(4, 6));

var mil = parseInt(item.slice(7, 10));

var time = mil + sec * 1000 + min * 1000 * 60;

return {

time,

min,

mil,

sec,

lyric: item.slice(10, item.length).replace(/[]]*/g, “”),

item

};

});

//实现拼接组合一个新的对象

arr.forEach((item, i) => {

if (i == 0) {

item.pre = 0;

} else {

item.pre = arr[i - 1].time;

}

});

return arr;

}

},

mutations: {

changeplaylist: function(state, value) {

state.playlist = value;

},

setPlayindex: function(state, indexvalue) {

state.playlistindex = indexvalue;

},

setLyric(state, value) {

state.lyric = value;

},

setCurrentTime(state, value) {

state.currentTime = value;

}

},

actions: {

//异步获取数据然后修改对应方法

reLyric(content, playload) {

content.commit(“setLyric”, playload);

}

},

modules: {

}

});

playMusics.vue

<svg class=“icon” aria-hidden=“true” @click=“$emit(‘back’)”>

{{playdetail.al.name}}

:class=“{active:(currentTime1000>=item.pre && currentTime1000<item.time)}”

v-for=“(item,i) in this.$store.getters.lyricContentFn”

:key=“i”

{{item.lyric}}

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent”>

playcontrolor.vue

{{playlist[playlistindex].al.name}}
滑动可以切换上下首哦

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent()”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent()”>

<playMusics

@back=“showpage=!showpage”

:isPause=“isPause”

:playdetail=“playlist[playlistindex]”

v-show=“showpage”

:playEvent=“playEvent”

<audio

ref=“audio”

:src=“https://music.163.com/song/media/outer/url?id=${this.playlist[this.playlistindex].id}.mp3

在这里插入图片描述`

//感觉歌词的时间出现的值和当前获取aduio获当前时间不是对应的值,给他对应成下一句歌词时间还是不行的,我也很费解–

`

在这里插入图片描述固定了一下歌词高度

playMusics.vue

<svg class=“icon” aria-hidden=“true” @click=“$emit(‘back’)”>

{{playdetail.al.name}}

:class=“{active:(currentTime1000>=item.pre && currentTime1000<item.time)}”

v-for=“(item,i) in this.$store.getters.lyricContentFn”

:key=“i”

{{item.lyric}}

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent”>

七、上一首和下一首歌曲切换实现

1.触发事件修改歌曲列表中当前播放的index索引值加一或减一

playMusics.vue

<svg class=“icon” aria-hidden=“true” @click=“$emit(‘back’)”>

{{playdetail.al.name}}

:class=“{active:(currentTime1000>=item.pre && currentTime1000<item.time)}”

v-for=“(item,i) in this.$store.getters.lyricContentFn”

:key=“i”

{{item.lyric}}

<svg class=“icon rotatedicon” aria-hidden=“true” @click=“goPlay(-1)”>

<svg v-if=“isPause” class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg v-else class=“icon play” aria-hidden=“true” @click=“playEvent”>

<svg class=“icon trans” aria-hidden=“true” @click=“goPlay(1)”>

  • 21
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2024Web前端面试面试官可能会关注一系列的技能和概念,包括但不限于HTML、CSS、JavaScript、前端框架(如React、Vue、Angular)、性能优化、响应式设计、浏览器兼容性、模块化和打包工具(Webpack、Rollup)、API交互、前端测试(如Jest、Mocha)、SEO、以及最近流行的技术趋势如WebAssembly、PWA(Progressive Web App)和GraphQL等。 具体的问题可能涵盖: 1. HTML5新特性的理解和使用,比如语义化的标签和表单控制。 2. CSS3样式和布局技巧,如Flexbox和Grid的使用。 3. JavaScript ES6+的新特性,比如箭头函数、模板字面量、Promise和Async/Await等。 4. 面向前端开发的JavaScript库和框架的最佳实践,如组件化开发和状态管理。 5. 了解并评价不同前端框架的核心思想和适用场景。 6. 浏览器渲染原理和性能优化策略,如懒加载、预渲染、缓存优化等。 7. 对跨域、同源策略和HTTPS的理解,以及处理JSONP或CORS的方法。 8. Webpack或Rollup的工作原理,以及如何配置它们来处理模块和打包。 9. 如何设计和实现可复用、可测试的前端代码结构。 10. 对现代前端测试的认识,包括单元测试、集成测试和端到端测试。 11. Web性能优化案例分享,如减少HTTP请求、压缩资源、CDN使用等。 12. 了解基本的SEO优化原则,如元标签、索引优化等。 13. 对现代前端架构,如服务端渲染、单页应用(SPA)和微前端的理解。 14. 最新前端技术动态,例如WebAssembly如何提升性能,PWA如何提供离线体验,以及GraphQL如何改进API设计。 如果你想深入了解前端面试题,建议关注权威技术博客、参加在线课程和模拟面试练习,不断更新自己的知识库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值