laravel 使用 vue 及 Ant-design-vue 依赖(Laravel5.6+Vue+Ant-design-vue集成搭建)

8 篇文章 0 订阅
4 篇文章 0 订阅

在这里插入图片描述
我们可以看一下app.js的代码,发现他是引入了vue,然后注册了一个组件,也就时Example.vue , Example.vue 中输出两句话,这是一个完整的组件,我们可以直接使用。
在这里插入图片描述
我们找到resources\views\welcome.blade.php 文件,将其修改为下面的代码,也就是吧原来的HTML删了,添加一个id为app的div,在其中使用app.js 中注册的组件,需要注意的就是要添加crsf-Token的验证meta标签,和引入 app.js 文件,这个js文件也可以去根目录中的 webpack.mix.js 文集中修改。

<!doctype html>
<html lang="{{ app()->getLocale() }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">
 
        <title>Laravel</title>
 
        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
 
    </head>
    <body>
        <div id="app">
            <example-component></example-component>
        </div>
    </body>
    <script src="/js/app.js"></script>
</html>

然后,我们npm run dev 一下然后到浏览器中看一下,我配置的虚拟主机访问地址是 vuxtest.cn npm编译好之后我们在浏览器查看发现已经安装好了。

Ant-design-vue安装
import Vue from 'vue'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
Vue.config.productionTip = false

Vue.use(Antd)

在这里插入图片描述

修改resource/js/components/ExampleComponent.vue

<template>
  <div id="components-button-demo-button-group">
    <h4>Basic</h4>
    <a-button-group>
      <a-button>Cancel</a-button>
      <a-button type="primary">OK</a-button>
    </a-button-group>
    <a-button-group>
      <a-button disabled>L</a-button>
      <a-button disabled>M</a-button>
      <a-button disabled>R</a-button>
    </a-button-group>
    <a-button-group>
      <a-button type="primary">L</a-button>
      <a-button>M</a-button>
      <a-button>M</a-button>
      <a-button type="dashed">R</a-button>
    </a-button-group>

    <h4>With Icon</h4>
    <a-button-group>
      <a-button type="primary">
        <a-icon type="left" />Go back
      </a-button>
      <a-button type="primary">
        Go forward<a-icon type="right" />
      </a-button>
    </a-button-group>
    <a-button-group>
      <a-button type="primary" icon="cloud" />
      <a-button type="primary" icon="cloud-download" />
    </a-button-group>
  </div>
</template>
<style>
#components-button-demo-button-group h4 {
  margin: 16px 0;
  font-size: 14px;
  line-height: 1;
  font-weight: normal;
}
#components-button-demo-button-group h4:first-child {
  margin-top: 0;
}
#components-button-demo-button-group .ant-btn-group {
  margin-right: 8px;
}
</style>

重新访问浏览器,能看到下图效果,说明你配置成功了

在这里插入图片描述

原文地址:https://www.gitshow.cn/a/1115

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ant-design-vue springboot开源集成框架提供了一种将ant-design-vue前端组件库与springboot后端框架集成的解决方案。ant-design-vue是一个优秀的前端UI框架,提供了丰富的组件和样式库,可以帮助开发者快速构建出美观且易于使用的用户界面。 在传统的前后端分离开发中,前端开发者需要自行选择UI框架,并通过RESTful接口与后端进行通信。而使用ant-design-vue springboot开源集成框架,可以直接使用ant-design-vue提供的组件,无需繁琐地搭建UI,同时可以通过框架提供的API与后端进行交互,简化了前后端的协作流程。 具体来说,ant-design-vue springboot开源集成框架基于springboot框架和vue.js框架,提供了一套配置文件和样板代码,用于快速搭建前后端集成项目。框架中已经集成ant-design-vue的组件库,并提供了一些自定义的样式和组件,使得开发者可以更方便地使用ant-design-vue的组件来构建用户界面。 同时,框架还提供了一些配置选项和API,用于与后端进行通信。开发者可以通过配置选项设置后端接口的URL,然后在前端代码中直接调用框架提供的API方法来发送请求和接收响应。这样,前端与后端之间的数据传输将更加方便和高效。 总之,ant-design-vue springboot开源集成框架是一个优秀的解决方案,可以帮助开发者快速搭建出前后端集成的项目,并使用ant-design-vue提供的丰富组件来构建美观且易于使用的用户界面。有了这个框架的帮助,开发者可以更专注于业务逻辑的实现,提高开发效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值