geecg-uniapp 同源策略 数据请求 页面渲染 ui库安装(3)

一,同源策略

(1)要是没有env 需要创建一个替换成后端接口
(2)因为他封装了 先找到http请求位置 一级一级找 然后进行接口修改 都改完运行即可
(3)appUpdata 修改接口 运行即可

二,数据请求

(1)创建页面 ,定义请求方式 , 因为他这个封装过 ,所以我们只能跟固有的进行数据请求
(2)报错了我们解决一下 看完整路径我们发现我们复制多了(路径是拼接的)这个是正确的
(3)又报错了 是请求错了 所以注意一下是 post 还是 get
(4)正确的写法展示

三,ui库安装

(1)我查了文档才知道他这个是用一个需要下一个ui组件 太麻烦了 所以直接下载一个完整的
跟着教程 安装运行 : uni-app官网 (dcloud.net.cn)

(2)下载插件 地址 : uni-ui - DCloud 插件市场


四,获取后台数据 进行页面渲染

(1)代码展示
复制代码
<template>
	<view>
	<cu-custom bgColor="bg-gradual-pink" :isBack="true">
		<block slot="content">荒石管理</block>
	</cu-custom>
		<view class="uni-container">
			<uni-table border stripe emptyText="暂无更多数据" >
				<uni-tr>
					<uni-th width="150" align="center">日期</uni-th>
					<uni-th width="150" align="center">{{name}}</uni-th>
					<uni-th align="center">地址</uni-th>
					<uni-th width="204" align="center">设置</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td>{{ item.date }}</uni-td>
					<uni-td>
						<view class="name">{{ item.name }}</view>
					</uni-td>
					<uni-td align="center">{{ item.address }}</uni-td>
					<uni-td>
						<view class="uni-group">
							<button class="uni-button" size="mini" type="primary">修改</button>
							<button class="uni-button" size="mini" type="warn">删除</button>
						</view>
					</uni-td>
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="change" /></view>
		</view>
	</view>
</template>
<script>
import tableData from './tableData.js'
export default {
	data() {
		return {
			searchVal: '',
			tableData: [],
			// 每页数据量
			pageSize: 10,
			// 当前页
			pageCurrent: 1,
			// 数据总量
			total: 0,
			loading: false,
			name:''
		}
	},
	onLoad() {
		this.selectedIndexs = []
		this.getData(1)
		
		let url = '/sabstone/smsSaBstoneWarehousing/list';
		this.$http.get(url).then(res=>{
			// console.log('结果',res)
			// console.log('结果',res.data.result.records)
			// this.name = res.data.code
			// this.name =res.data.result.records.length
			
			this.name =res.data.result.records[0].sabwOpuser
			
			console.log('结果',res.data.result.records)
				
		})
		
		
	},
	methods: {
	
		// 分页触发
		change(e) {
			this.$refs.table.clearSelection()
			this.selectedIndexs.length = 0
			this.getData(e.current)
		},
		// 搜索
		search() {
			this.getData(1, this.searchVal)
		},
		// 获取数据
		getData(pageCurrent, value = '') {
			this.loading = true
			this.pageCurrent = pageCurrent
			this.request({
				pageSize: this.pageSize,
				pageCurrent: pageCurrent,
				value: value,
				success: res => {
					// console.log('data', res);
					this.tableData = res.data
					this.total = res.total
					this.loading = false
				}
			})
		},
		// 伪request请求
		request(options) {
			const { pageSize, pageCurrent, success, value } = options
			let total = tableData.length
			let data = tableData.filter((item, index) => {
				const idx = index - (pageCurrent - 1) * pageSize
				return idx < pageSize && idx >= 0
			})
			if (value) {
				data = []
				tableData.forEach(item => {
					if (item.name.indexOf(value) !== -1) {
						data.push(item)
					}
				})
				total = data.length
			}

			setTimeout(() => {
				typeof success === 'function' &&
					success({
						data: data,
						total: total
					})
			}, 500)
		}
	}
}
</script>
<style>
/* #ifndef H5 */
/* page {
	padding-top: 85px;
} */
/* #endif */
.uni-group {
	display: flex;
	align-items: center;
}
</style>
(2)页面展示
相关推荐
用户6990304848752 天前
try catch使用场景 处理同步代码错误兼容用的
javascript·uni-app
ITKEY_2 天前
uniapp微信开发者工具 更改AppID失败 touristappid
uni-app
Geek_Vison2 天前
APP瘦身实战:从80MB+砍到15MB——基于小程序容器技术剥离APP非核心业务的实践分享
小程序·uni-app·mpaas
CHB3 天前
HDC2026 演讲实录|AI 驱动的跨端进化:利用 uni-agent 快速构建高性能鸿蒙应用
uni-app·harmonyos
2501_915918413 天前
iOS App性能测试工具的实现方法与优化循环指南
android·ios·小程序·https·uni-app·iphone·webview
斯内普吖3 天前
(开源)高校素拓分管理系统小程序实战指南 基于 Java + SpringBoot + uni-app + Vue + MySQL
java·spring boot·mysql·小程序·uni-app·开源
海阔天空66883 天前
uniapp开启调试模式
uni-app·uniapp开启调试模式
anyup4 天前
分享 5 套 uni-app 实用主题,一键适配暗黑模式
前端·uni-app·视觉设计
gg159357284604 天前
Uni-app跨平台开发全解课程:从零基础到企业级多端落地实战
vue.js·uni-app
xshirleyl5 天前
uniapp小兔鲜儿day3
uni-app