vue+element+axios 创建单页

本文介绍了如何使用Vue、Element UI和Axios来创建一个单页应用程序。首先通过HBuilderX建立基础工程,然后在HTML头部引入Vue、Element UI和Axios的库。为了确保IE9的兼容性,需要在body中添加提示,并避免使用不被IE9支持的箭头函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近有个需求是前端是一个单页,后台做管理,后台用vue+element ,索性单页也就用vue+element。

vue+element:ui
axios:接口调用

1.使用HBuilderX创建一个普通的工程,然后创建一个.html界面。
2.在head里面引入所需要的库(vue、element、axios 等)。可使用bootcdn(https://www.bootcdn.cn/) 查找库

<script src="https://cdn.bootcss.com/babel-polyfill/7.4.4/polyfill.min.js"></script>
<script src="https://cdn.bootcss.com/es6-promise/4.1.1/es6-promise.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.bootcss.com/element-ui/2.9.2/index.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script>
<link href="https://cdn.bootcss.com/element-ui/2.9.2/theme-chalk/index.css" rel="stylesheet">

3.ie9兼容

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >

3.1 在boby添加提醒

<!--[if lt IE 9]>
<div class="topbar">XXX系统不支持当前所使用的浏览器,推荐安装 <a href="https://www.google.com/chrome/" target="_blank">谷歌浏览器</a> 或者 <a href="http://www.firefox.com.cn/download/" target="_blank">火狐浏览器</a> 获取更好的使用体验。</div>
<script src="https://bce.bdstatic.com/console/json2.js"></script>
<script src="https://bce.bdstatic.com/console/html5shiv.min.js"></script>
<script>(function(){var c="esui-";var b=["Calendar","Crumb","Dialog","Label","Month-View","Pager","Panel","Range-Calendar","Region","Rich-Calendar","Schedule","Search-Box","Sidebar","Tab","Table","Text-Box","Text-Line","Tip","Tip-Layer","Tree","Wizard","Toast"];for(var a=0;a<b.length;a++){document.createElement(c+b[a])}}());</script>
<![endif]-->

注:ie9 不支持 => 语法 可使用 function() 语法替代

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值