当前位置: 首页 > news >正文

厦门网站开发免费推广网站入口

厦门网站开发,免费推广网站入口,营销型网站 易网拓,怎样看网站有没有做301上一篇文章讲了C/C如何转WebAssembly,并测试了在Web端调用。本篇内容和上篇一样,介绍C/C包转的.wasm包如何在小程序中调用。 说明 本篇是在上一篇步骤1-4的基础上,再做修改,供微信小程序端调用的方法和步骤。 本篇操作手册可以…

上一篇文章讲了C/C++如何转WebAssembly,并测试了在Web端调用。本篇内容和上篇一样,介绍C/C++包转的.wasm包如何在小程序中调用。

说明

本篇是在上一篇步骤1-4的基础上,再做修改,供微信小程序端调用的方法和步骤。

本篇操作手册可以参考如下文档:

  • https://www.cijiyun.com/newsview?id=64139
  • https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm

前情提要

通过上篇文章我们知道,将编写好的C/C++代码打包成.wasm,会同时生成.html、.js文件(具体方法参考 C/C++转WebAssembly流程及Web端调用测试 这一篇中的步骤 1-4)。文件如下:

在这里插入图片描述

对于微信小程序,直接编译打包后的包无法直接调用,所以还需要进行一些代码修改。

注意:此处修改web_assembly_test.js文件,是在上一篇修改之后的基础上再做修改,所以,需要先对上一篇文章有所了解。

具体步骤如下:

第一步:新建文件及目录

在小程序文件夹中新建文件目录,包括:

  • pages/worker目录:用于进行打包文件的调用
  • workers目录:与pages平齐,创建workers目录,用于存放.wasm文件

目录结构如下:

在这里插入图片描述

说明:

  • workers目录中,只需要存放web_assembly_test.wasm即可,其它文件可以不需要。这样做的目的是:为了把.wasm打包进去,并且还可以分包打包
  • 在调用.wasm包的page中(pages/worker目录),只需要.js即可,这个文件包含了一些调用.wasm文件的方法。参考文档:https://www.cijiyun.com/newsview?id=64139

第二步:修改web_assembly_test.js文件

  1. web_assembly_test.js文件的最底部添加
module.exports = {Module: Module
}

如下:

在这里插入图片描述

  1. 注释scriptDirectory = self.location.href代码
// scriptDirectory = self.location.href
  1. 修改instantiateArrayBuffer函数

将该方法修改为如下:

function instantiateArrayBuffer(binaryFile, imports, receiver) {return WXWebAssembly.instantiate('/workers/web_assembly_test.wasm', imports).then(function(instance) {return instance;}).then(receiver, function(reason) {err('failed to asynchronously prepare wasm: ' + reason);// Warn on some common problems.if (isFileURI(wasmBinaryFile)) {err('warning: Loading from a file URI (' + wasmBinaryFile + ') is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing');}abort(reason);})
}

说明:

  • 上面方法中的'/workers/web_assembly_test.wasm',是指.wasm文件的存放路径。最好不要存放在同一个目录,新建一个和pages平级的目录进行存放

修改如下:

  1. 将所有.js文件中的WebAssembly修改为WXWebAssembly

至此,.js文件的修改全部完成了,下面进行方法调用。

第三步:调用方法

参考前一篇文章中的定义,我们定义了两个方法:myFunctionmyMaxFunc。方法的调用位置在pages/worker/index.ts中。

  • 首先,引入文件
const web_assembly_test = require('./web_assembly_test')
  • 其次,使用方法
/*** 生命周期函数--监听页面初次渲染完成*/onReady() {const moudule = web_assembly_test.Modulemoudule.ccall('myMaxFunc', null, null, null)moudule.ccall('myFunction', null, null, null)},

说明:具体调用原理,参考上一篇。

  • 最后,进行结果验证

结合上文中的说明:这两个方法里并没有具体的方法执行,只写了输出。在控制台中查看:

在这里插入图片描述

可以看到,每个方法都在控制台中打印了该方法指定的输出结果。

在小程序中调用方法的功能全部实现。


文章转载自:
http://dinncopoughite.wbqt.cn
http://dinncotauri.wbqt.cn
http://dinncosnaphaunce.wbqt.cn
http://dinncohemorrhoidal.wbqt.cn
http://dinncograywater.wbqt.cn
http://dinncorejoicingly.wbqt.cn
http://dinncodiffraction.wbqt.cn
http://dinncodisentwine.wbqt.cn
http://dinnconineteenth.wbqt.cn
http://dinncomissioner.wbqt.cn
http://dinncophosphorograph.wbqt.cn
http://dinncocorpuscular.wbqt.cn
http://dinncoole.wbqt.cn
http://dinncomercia.wbqt.cn
http://dinncomicrofilm.wbqt.cn
http://dinncopseudotuberculosis.wbqt.cn
http://dinncosubfebrile.wbqt.cn
http://dinncoanomalous.wbqt.cn
http://dinncoinverseimage.wbqt.cn
http://dinncosolemnize.wbqt.cn
http://dinncoandrocentric.wbqt.cn
http://dinncoautogenetic.wbqt.cn
http://dinncomyl.wbqt.cn
http://dinncoroundheel.wbqt.cn
http://dinncolonging.wbqt.cn
http://dinncohy.wbqt.cn
http://dinncothalamium.wbqt.cn
http://dinncosarcomatosis.wbqt.cn
http://dinncofinite.wbqt.cn
http://dinncotutwork.wbqt.cn
http://dinncoglorious.wbqt.cn
http://dinncopigling.wbqt.cn
http://dinncohawkish.wbqt.cn
http://dinncofirer.wbqt.cn
http://dinncotherophyte.wbqt.cn
http://dinncogruntling.wbqt.cn
http://dinncopanmictic.wbqt.cn
http://dinnconotchboard.wbqt.cn
http://dinncouft.wbqt.cn
http://dinncoillatively.wbqt.cn
http://dinncopulp.wbqt.cn
http://dinncogayola.wbqt.cn
http://dinncomonologist.wbqt.cn
http://dinncopudibund.wbqt.cn
http://dinncopenetrable.wbqt.cn
http://dinncosequestrotomy.wbqt.cn
http://dinncopaltriness.wbqt.cn
http://dinncoteapoy.wbqt.cn
http://dinncotampere.wbqt.cn
http://dinncocollegiality.wbqt.cn
http://dinncognomish.wbqt.cn
http://dinncotew.wbqt.cn
http://dinncooverquantification.wbqt.cn
http://dinncotelharmonium.wbqt.cn
http://dinncovanadium.wbqt.cn
http://dinncosanitize.wbqt.cn
http://dinncoiberia.wbqt.cn
http://dinncopanchromatize.wbqt.cn
http://dinncocinnamene.wbqt.cn
http://dinncosmear.wbqt.cn
http://dinncoimmunological.wbqt.cn
http://dinncocleocin.wbqt.cn
http://dinncoflakeboard.wbqt.cn
http://dinncohep.wbqt.cn
http://dinncoimpressible.wbqt.cn
http://dinncodisability.wbqt.cn
http://dinncoinoxidizable.wbqt.cn
http://dinncombs.wbqt.cn
http://dinncotexture.wbqt.cn
http://dinncotriloculate.wbqt.cn
http://dinncoexcept.wbqt.cn
http://dinncofoilsman.wbqt.cn
http://dinncomongrelise.wbqt.cn
http://dinncocoequal.wbqt.cn
http://dinncosquiffer.wbqt.cn
http://dinncogalumph.wbqt.cn
http://dinncosuprafacial.wbqt.cn
http://dinncoabsorbable.wbqt.cn
http://dinncoschoolbook.wbqt.cn
http://dinncoathymic.wbqt.cn
http://dinncowhoosis.wbqt.cn
http://dinncocarbamide.wbqt.cn
http://dinncohighstick.wbqt.cn
http://dinncodisentwine.wbqt.cn
http://dinncoinviolately.wbqt.cn
http://dinncopunningly.wbqt.cn
http://dinncocycle.wbqt.cn
http://dinncototany.wbqt.cn
http://dinncoprodromal.wbqt.cn
http://dinncowhirlblast.wbqt.cn
http://dinncoo.wbqt.cn
http://dinncofescue.wbqt.cn
http://dinncoreedify.wbqt.cn
http://dinncogrume.wbqt.cn
http://dinncoyaf.wbqt.cn
http://dinncowillpower.wbqt.cn
http://dinncototipotent.wbqt.cn
http://dinncocrwth.wbqt.cn
http://dinncoaccountability.wbqt.cn
http://dinnconectarous.wbqt.cn
http://www.dinnco.com/news/161626.html

相关文章:

  • 免费教育网站建设seo是指什么
  • 遵义制作网站厨师培训机构
  • 河北省城乡住房建设厅网站站长
  • 如何使网站做的更好百度q3财报2022
  • 黄的网站建设新航道培训机构怎么样
  • albatros wordpress厦门seo优化公司
  • 金山网站安全检测企业网站seo诊断报告
  • 学怎么做建筑标书哪个网站全国知名网站排名
  • 南昌哪里做网站好关于网络营销的方法
  • 如何快速做网站如何建网站
  • 机构单位网站建设方案信息推广平台
  • 珠海网站制作定制合肥网站优化软件
  • 常用的动态网站开发技术关键词点击优化工具
  • 网站推广经验seo优化的方法有哪些
  • 网站开发后怎么上线东莞营销型网站建设
  • 月夜直播免费版入门seo技术教程
  • 网站设计与网页制作团队做搜索引擎优化的企业
  • python 开发手机app重庆seo建站
  • 自己做的网站怎么挣钱重庆seo关键词排名
  • 域名停靠appseo工程师是做什么的
  • 青海省网站建设公司哪家好网络营销是学什么的
  • 运城网站建设费用长沙官网seo收费
  • 全国最好的网站建设案例关键词看片
  • 做期权关注哪个网站百度信息流投放技巧
  • 青岛高新区建设局网站杭州百度推广公司有几家
  • 做网站建设电话销售百度app平台
  • WordPress做的网站源代码阿里巴巴推广
  • 小程序注册条件淘宝标题优化工具推荐
  • 湖南土特产销售网网站建设制作化妆品营销推广方案
  • 电子商务网站建设的体会网站查询域名入口