通過(guò)官網(wǎng)的命令去創(chuàng)建項(xiàng)目
- 全局安裝vue-cli
yarn add @vue/cli -g
- 查看版本是否是已經(jīng)在3.0以上衫哥,沒(méi)有的話執(zhí)行孝治,這邊版本@vue/cli 4.5.15
yarn global upgrade --latest @vue/cli
vue --version
- 安裝模板
vue create -p dcloudio/uni-preset-vue ts-test
image.png
- 安裝過(guò)程可能會(huì)很慢冈欢,這邊是下載安裝了蠻長(zhǎng)一段時(shí)間活玲。翻墻了也效果不佳瞒津。
$ vue create -p dcloudio/uni-preset-vue tstest
Fetching remote preset dcloudio/uni-preset-vue...
Vue CLI v4.5.15
? Creating project in /Users/fd/Desktop/Radish/uniapp-framework/tstest.
?? Installing CLI plugins. This might take a while...
yarn install v1.22.10
info No lockfile found.
[1/4] ?? Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
[2/4] ?? Fetching packages...
[3/4] ?? Linking dependencies...
- 通過(guò)命令
yarn dev:mp-weixin
運(yùn)行,毫無(wú)疑問(wèn)的来氧,就報(bào)錯(cuò)了诫给。
3.png
這個(gè)錯(cuò)誤大概意思是typescript的版本問(wèn)題,看了下package.json的ts的版本是3.0 + 升級(jí)到4.0就好了
image.png
- 運(yùn)行中報(bào)錯(cuò) createStore 函數(shù)不存在啦扬,但是通過(guò)代碼點(diǎn)擊查找中狂,明顯是有存在這個(gè)方法。在hbuildx中扑毡,發(fā)現(xiàn)vue的版本還是2.0吃型,改為3.0
image.png