使用vue+element ui+.net core创建项目并加载后台数据(vs code)

  • Post author:
  • Post category:vue


1.打开vscode,点击终端,首先先创建保存文件目录

cd c:/demo3

2.配置项目,这里是写比较详细的文章

https://www.cnblogs.com/zyskr/p/10609288.html

3.安装elment ui

https://www.cnblogs.com/zmoneyz/p/12993006.html

4.安装vue+axios,接口

https://w.cnblogs.com/yieix/p/12244790.html

5…加入接口渲染列表

https://w.cnblogs.com/yieix/p/12244790.html

组件网站

https://element.eleme.cn/#/zh-CN/component/table

6.创建后台

去管理newget 程序包中下载 NPoco,mysql.data

7.后台去startup类中的ConfigureServices复制

services.AddScoped(x =>

{


return new Database(“Server=127.0.0.1;Uid=root;Pwd=123456;Database=users;”, DatabaseType.MySQL, MySql.Data.MySqlClient.MySqlClientFactory.Instance);

});

// 开启跨域 https://www.cnblogs.com/linyijia/p/12981830.html

services.AddCors(o =>

o.AddPolicy(“CorsPolicy”,

builder => builder

                  .AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed(p => true)
            ));

8.Configure中复制

// 跨域

app.UseCors(“CorsPolicy”);

9,添加实体类

10.修改WeatherForecastController

private readonly ILogger _logger;

private readonly IDatabase _database;

    public WeatherForecastController(ILogger<WeatherForecastController> logger, IDatabase database)
    {
        _database = database;
        _logger = logger;

    }

    [HttpGet]
    public IEnumerable<usertable> Get()
    {
        var _users = _database.Fetch<usertable>("select * from usertable");
        return _users;

    }

9.前端输入npm run dev 运行

10.如有遇到运行不出来 找 build–webpack.base.conf—// …(config.dev.useEslint ? [createLintingRule()] : []),去掉createLintingRule()



版权声明:本文为buchishutiao原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。