uniapp 打包APP 使用 Galacean Effects 的特效

访问 Galacean Editor

新建test1文件夹,将导出的内容复制进去

新建test2.vue文件

复制代码
<template>
	<view v-html="html">
		
	</view>
	<view v-show="false" :data="url" :change:data="requestModule.realRequest"></view>
</template>

<script setup>
	import { onMounted } from 'vue'
	import { ref } from 'vue'
	
	
	const html = ref('<div id="container" style="width: 100vw; height: 100vh;"></div>')

	const url = ref('')
	
	onMounted(() => {
	  //let container = document.getElementById('container');
		
	  
	  //console.log(12232262323);
	  //console.log(container);
	  
	  url.value = './static/test1/game.json';
	})
</script>


<script module="requestModule" lang="renderjs">
	import { Player } from '@galacean/effects';
	export default {
		methods: {
			realRequest(newValue, oldValue) {
				console.log(4111);
				console.log(newValue);
				//console.log(oldValue);
				
				if(newValue != null && newValue != ''){
					let container = document.getElementById('container');
					console.log(container);
					
					// 1. 实例化一个播放器
					const player = new Player({
					  container: container,
					  // 初始化 Player 或 loadScene 时遇到的异常
					  onError: (err, ...args) => {
					    // 降级逻辑,以下仅供参考
					    container.style.backgroundImage = 'url("替换为降级图路径/链接")';
					  },
					});
					
					// 2. 加载并播放动效资源
					void player.loadScene(newValue);
				}
			}
		}
	};
</script>

<style>
	       
</style>

修改 url.value = './static/test1/game.json'; 为你复制进test1目录下的.json文件的路径,即可看到特效

相关推荐
bug总结1 小时前
uniapp的easycom自动组件注册机制
uni-app
HF_code3 小时前
uniapp-history路由深度指南
uni-app
suliqiang4 小时前
【前端技术】 Web 前端技术36年 演进全景图
信息可视化·微信小程序·小程序·前端框架·uni-app·人机交互·xcode
梦曦i1 天前
uni-router v0.2.0重磅发布:全链路拦截+重复导航优化
前端·uni-app
EatFan1 天前
【实战经验】uni-app使用 SSE 踩坑,EventSource不支持怎么办?
android·后端·ios·uni-app
凡泰AI1 天前
如何为政务 APP 搭建开放平台,实现多部门、第三方供应商标准化入驻与统一管理
android·大数据·小程序·uni-app·app·政务
梦曦i2 天前
@meng-xi/uni-router 未来展望:夯实基础、深化体验、探索前沿
前端·uni-app
2501_916007472 天前
使用Apple Dashboards显示和自定iOS应用性能指标与数据可视化指南
android·ios·小程序·https·uni-app·iphone·webview
爱折腾的编程老炮2 天前
潮玩小程序订单模型-一张表装下所有玩法
spring boot·小程序·uni-app
两个人的幸福online2 天前
UniApp 对接 IM 即时通讯全攻略(下篇)
uni-app