Code Monkey home page Code Monkey logo

music's Introduction

music

概述

项目是基于Vue,成品是一个移动端的单页面应用音乐播放器,来源于imooc的实战课程,自己通过看视频来完成这个应用。

项目的大致流程是Vue-cli构建开发环境,分析需求,设计构思,规划目录结构,开始编码。

数据来源

所有数据都来自于QQ音乐,抓取自QQ的接口,大部分接口都是JSONP,抓取比较容易,其中一些接口限制了host,不能直接抓取,采用的方法是用axios代理,设置header,以此绕过host的限制。

技术栈

Vue+Vuex+Vue-Router+Vue-cli+Stylus+Axios+Better-scroll

难点

player组件

播放器组件可谓是整个项目的核心,当然数据处理和用户体验方面也是不简单的(播放器是全局组件,放在App.vue下面,通过Vuex传递数据,触发action提交mutation,从而使播放器开始工作。

数据处理

通过调用QQ音乐的JSONP接口,获取的数据并不能直接拿来用,需要做进一步的规格化。

在请求JSONP的时候,用到了一个JSONP库。使用时,就是将请求的参数拼接在请求url上,然后调用这个库的jsonp方法。

将请求的数据格式化后再通过Vuex传递,组件间共享,实现歌曲的播放切换等。

交互体验

该项目的很多地方都涉及到滚动,包括下拉滚动,下拉滚动刷新等,这里面用到了一个js库better-scroll,来实现所有涉及到的滚动。

其他动画包括了Vue的transition动画,路由之间切换时的简单动画,播放器打开时的动画。

打开页面时的加载Loading效果,其实就是一个Loading组件。

为了减少流量,图片加载使用了懒加载的方式。

总结

自己通过这个项目学到很多关于vue单页面开发的知识,还需要更加融合贯通,毕竟是自己的第一个vue作品,完成度也不是很高,但是希望在日后的学习中能够有所提高。

music's People

Contributors

xiechengyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.