通過官網的命令去創建項目
- 全局安裝vue-cli
yarn add @vue/cli -g
- 查看版本是否是已經在3.0以上,沒有的話執行,這邊版本@vue/cli 4.5.15
yarn global upgrade --latest @vue/cli
vue --version
- 安裝模板
vue create -p dcloudio/uni-preset-vue ts-test
image.png
- 安裝過程可能會很慢,這邊是下載安裝了蠻長一段時間。翻墻了也效果不佳。
$ 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...
- 通過命令
yarn dev:mp-weixin
運行,毫無疑問的,就報錯了。
3.png
這個錯誤大概意思是typescript的版本問題,看了下package.json的ts的版本是3.0 + 升級到4.0就好了
image.png
- 運行中報錯 createStore 函數不存在,但是通過代碼點擊查找,明顯是有存在這個方法。在hbuildx中,發現vue的版本還是2.0,改為3.0
image.png