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