当前位置: 移动技术网 > IT编程>开发语言>.net > net core + vue

net core + vue

2018年12月12日  | 移动技术网IT编程  | 我要评论

本月上映电影,潮拜武当接档,yyplatform.exe

node.js下载地址   https://nodejs.org/en/download/
安装完成后 找到 node.js command prompt  打开即为node的命令窗口
执行命令       npm install -g @vue/cli
查看vue版本   vue --version
创建一个新项目  vue create hello-world
运行项目            npm run serve
打包项目             npm run build
打包之后得到dist文件夹  可以将打包的发布到iis 参考  https://www.jianshu.com/p/7cc266438f09 


新建net core项目
nuget 安装 
microsoft.aspnetcore.spaservices 2.11
vueclimiddleware 2.11
把 hello-world项目复制到core项目根目录

  public void configureservices(iservicecollection services)
  {
       services.addmvc().setcompatibilityversion(compatibilityversion.version_2_1);

       services.addspastaticfiles(configuration => { configuration.rootpath = "hello-world/dist"; });
  }


    app.usespa(spa =>
    {
        spa.options.sourcepath = "hello-world";

         if (env.isdevelopment())
         {
            spa.usevuecli(npmscript: "serve", port: 8080); // optional port
         }
    });

直接运行项目即可 访问 http://localhost:8080/ 就是你的core项目啦

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网