uniapp error页面配置

uniapp暂不支持自定义webview所以我们用自带的error
首先在根目录新建生成此文件hybrid/html/error.html
在这里插入图片描述
在manifest.json(源码试图)中配置error,必须在app-plus下(这里要注意路径问题否则页面会找不到)在这里插入图片描述
error页面是一个单独页面不支持upx,rem在移动端也不生效(尚不知原因),我直接用的px

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="MobileOptimized" content="320" />
		<title>Error</title>
		<script type="text/javascript">
			var ab_ = {
				plusReady(callback) {
					if (window.plus) {
						callback()

					} else {
						document.addEventListener('plusready', callback)
					}
				}
			}

			ab_.plusReady(function() {
				var native
				var center
				try {
					native = plus.os.name.toLowerCase()
					if (native === 'android') {
						center = plus.android.importClass("com.absir.uniplugin.AbCenter").ME()

					} else if (plus.ios) {
						center = plus.ios.importClass("AbCenter").ME()
					}

				} catch (e) {
					console.error(e)
				}

				ab_.native = native
				ab_.center = center
				ab_.postEvent = function(event, paras) {
					if (center) {
						if (native === 'android') {
							center.postEvent(event, paras)

						} else {
							plus.ios.invoke(center, 'postEvent:paras:', event, paras)
						}
						return true
					}
				}

				plus.key.addEventListener('backbutton', function() {
					backClick()
				}, false)
			})

			function backClick() {
				(history.length == 1) && closeClick();
				var c = setTimeout(function() {
					closeClick();
				}, 1000);
				window.onbeforeunload = function() {
					clearTimeout(c);
				}
				history.go(-2);
			}

			function closeClick() {
				ab_.postEvent('message', 'backProj')
			}

			function restartClick() {
				plus.runtime.restart()
			}
		</script>
		<style>
			* {
				-webkit-user-select: none;
			}

			html,
			body {
				margin: 0px;
				padding: 0px;
				width: 100%;
				height: 100%;
				text-align: center;
				word-break: break-all;
				-webkit-touch-callout: none;
				-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
			}

			.button {
				width: 60%;
				font-size: 18px;
				font-weight: normal;
				text-decoration: none;
				text-align: center;
				padding: .5em 0em;
				margin: .5em auto;
				color: #333333;
				border-radius:22px;
			/* 	background-color: #EEEEEE;
				border: 1px solid #CCCCCC;
				-webkit-border-radius: 5px;
				border-radius:22px; */
			}

			.button:active {
				background-color: #CCCCCC;
			}
			.back{
				color: #6767EA;
				border: 1px solid #6767EA;
			}
			.reload{
				color: #fff;
				border: none;
				background: linear-gradient(to right, #6767EA, #75ACFF);
				margin-left: 60upx;
			}
		</style>
	</head>
	<body>
		<div style="width:100%;height:20%;"></div>
		<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="84px" height="94px" viewBox="0 0 84 94" enable-background="new 0 0 84 94" xml:space="preserve">  <image id="image0" width="84" height="94" x="0" y="0"
		    href="你的svg" />
		</svg>
		<p style="font-size:18px;font-weight:bolder;">抱歉,没有找到您请求的页面</p>
		<p id="info" style="font-size:12px;"></p>
		<!--<div class="button" onclick="history.back()">Retry</div>-->
		<div class="button back" onclick="backClick()">返回</div>
		<div class="button back" onclick="closeClick()">关闭</div>
		<div class="button reload" onclick="restartClick()">刷新</div>
	</body>
</html>
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是 Uniapp 中使用 PayPal 支付的配置代码: 1. 在 uniapp 的 pages.json 中添加支付页面: ``` { "pages": [ { "path": "pages/paypal/pay", "style": { "navigationBarTitleText": "PayPal支付" } } ] } ``` 2. 在支付页面 pay.vue 中,添加 PayPal 支付按钮: ``` <template> <view class="container"> <button type="primary" @click="payWithPayPal">Pay with PayPal</button> </view> </template> <script> export default { methods: { payWithPayPal() { // PayPal 支付代码 } } } </script> ``` 3. 在支付页面 pay.vue 中,编写 PayPal 支付代码: ``` payWithPayPal() { const self = this; const PAYPAL_CLIENT_ID = 'YOUR_PAYPAL_CLIENT_ID'; paypal.Buttons({ createOrder: function(data, actions) { return actions.order.create({ purchase_units: [ { amount: { value: '100.00' } } ] }); }, onApprove: function(data, actions) { return actions.order.capture().then(function(details) { uni.showToast({ title: 'Payment completed!', icon: 'success' }); }); }, onError: function(err) { uni.showToast({ title: 'Payment error: ' + err, icon: 'none' }); } }).render('#paypal-button-container'); } ``` 其中,需要将 PAYPAL_CLIENT_ID 替换为自己的 PayPal 客户端 ID。 4. 在支付页面 pay.vue 中,添加 PayPal 支付按钮的容器: ``` <template> <view class="container"> <button type="primary" @click="payWithPayPal">Pay with PayPal</button> <div id="paypal-button-container"></div> </view> </template> ``` 5. 在支付页面 pay.vue 中,导入 PayPal JS SDK: ``` <script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID"></script> ``` 其中,需要将 YOUR_CLIENT_ID 替换为自己的 PayPal 客户端 ID。 6. 在支付页面 pay.vue 中,运行支付页面: ``` export default { onReady() { this.payWithPayPal(); } } ``` 这样,当支付页面 pay.vue 加载完成后,就会自动运行 payWithPayPal() 方法,展示 PayPal 支付按钮。用户点击按钮后,便可以进行 PayPal 支付。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

给钱,谢谢!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值