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文件的路径,即可看到特效

相关推荐
古韵15 小时前
你的 uni-app 分页,一个 hook 搞定竞态和加载
javascript·vue.js·uni-app
游戏开发爱好者821 小时前
iOS应用加固方案全解析:源码加固与IPA在线加固对比
android·macos·ios·小程序·uni-app·cocoa·iphone
满栀5851 天前
uni-app 小程序开发实战:从路由踩坑、数据对接到 UI 优化的全方位复盘
ui·uni-app·notepad++
他叫自己MR张2 天前
uni-app 应用启动报uni-ad业务状态异常(-9002)【已解决】
uni-app
2501_915909062 天前
iOS应用性能监控 Instruments工具与崩溃日志分析完整指南
android·ios·小程序·https·uni-app·iphone·webview
2501_915918413 天前
详解iOS App上架至App Store的全流程步骤与注意事项
android·macos·ios·小程序·uni-app·cocoa·iphone
anyup3 天前
终于在今天入选了 Gitee GVP,这真值得庆祝~
前端·uni-app·开源
虚惊一场3 天前
撤销为什么只需要 pop:用事件重放实现离线台球计分
微信小程序·uni-app
虚惊一场3 天前
从一个小程序到一座工具箱:uni-app 分包与 Flask 微服务实践
微信小程序·uni-app