Vue是构建用户界面的先进框架。它不像其余全能的框架,Vue是从头开始逐渐设计起来的。核心库只专一于视图层,它很是容易上手而且能够与其余库或现有的项目进行整合。在另外一方面,当与相关工具和支持库结合使用时,Vue也能完美的驱动复杂的单页面应用。小女子深知 “纸上得来终觉浅,绝知此事要躬行.”,且有着大多数女孩纸的优势爱购物逛各类购物平台( ̄▽ ̄),因而开始了vue2.0仿半糖APP的故事,而半塘做为一个为大众推荐好物的平台,天然最重要的就是可以搜索好物和发现好物,因此针对这自认为最重要的两个功能开始了代码世界的遨游。
css
( ̄︶ ̄)↗预览demo(用chrome浏览器切换手机模式预览更佳,发文章的功能点击底部菜单栏+哦,搜索请搜索口红化妆品等关键字,其余数据还没mock进去...)
( ̄︶ ̄)↗源代码
html
login() { var myreg =/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; if(this.phonenumber.length == 0 ){ alert('请输入手机号码!'); } else if(!myreg.test(this.phonenumber)){ alert('请输入有效的手机号!') } else{ this.$store.commit('checking') this.$router.push({path:'/'}) } } <router-link :to="isLogin" tag="li"> <span class="icon icon-info"></span> <p class="home_text">消息</p> </router-link> <router-link :to="isLoading" tag="li"> <span class="icon icon-my"></span> <p class="home_text">个人</p> </router-link>
created () { this.inputText = this.$store.state.inputText this.axios.get('http://easy-mock.com/mock/5940ff968ac26d795f00bd9e/care/list/care/list') .then((res)=>{ console.log(res.data) let message = res.data for(let i in message){ let item = i; console.log(item); console.log(this.inputText); console.log(item.indexOf(this.inputText)); if(item.indexOf(this.inputText)!== -1){ this.contents = message[item] return } } if(this.contents.length){ this.message = true }else{ this.message = false this.$refs.tip.className='tipshow' console.log('没有找到哦'); } }) .catch((error) => {console.log(error)}) }
this.headline=this.$store.state.headline; this.content=this.$store.state.content; for(let i=0;i<this.$store.state.picurl.length;i++){ this.fileListurl.push(this.$store.state.picurl[i]); } }
handleRemove(file, fileList) { this.fileListurl=fileList; console.log('删除'); console.log(this.fileListurl); }, upload (response,file,fileList) { let that = this; console.log('上传文件'); console.log(file); console.log(typeof that.$store.state.picurl); that.$store.dispatch('upload',file.url); console.log(that.$store.state.picurl); console.log('store上传成功'); console.log(this.$store.state.picurl); this.$refs.see.disabled=false this.$refs.see.className="pre_see_active" this.$refs.send.disabled=false this.$refs.send.className="send_active" }
pre_see(){ this.fileListurl=this.$store.state.picurl; this.$store.dispatch('writetitle',this.headline); this.$store.dispatch('writecontent',this.content); this.$router.push({path:'/pre_see'}) }
send_out(){ this.$store.dispatch('writetitle',this.headline); this.$store.dispatch('writecontent',this.content); console.log(this.$store.state.content) var str = JSON.stringify(this.$store.state.picurl); localStorage.setItem("pics",str); localStorage.setItem('title',this.$store.state.headline); localStorage.setItem('content',this.$store.state.content); console.log(this.headline); console.log(this.content); let instance = Toast('发布成功'); setTimeout(() => { instance.close(); this.$router.push({path:'/asuccess'}) }, 2000); }
* 这个项目到目前的程度也作完挺久的了,一直没有写总结,这也是个毛病,由于不少东西当时以为须要注意,如今倒以为没什么,因此之后必定要边作边总结,让后来的人能更快的上手。还有购物和晒照功能以及数据的懒加载等在向我招手,我会尽快握住他们的。
vue
# install dependencies npm install # serve with hot reload at localhost:8080 npm run dev # build for production with minification npm run build # build for production and view the bundle analyzer report npm run build --report
For detailed explanation on how things work, checkout the guide and docs for vue-loader.
"# bantang"html5