美文网首页vue
uniapp+vue3.0+typescript

uniapp+vue3.0+typescript

作者: RadishHuang | 来源:发表于2021-12-06 13:39 被阅读0次

    通过官网的命令去创建项目

    • 全局安装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

    相关文章

      网友评论

        本文标题:uniapp+vue3.0+typescript

        本文链接:https://www.haomeiwen.com/subject/sqbnzltx.html