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

网站设置搜索框是什么知识点有没有什么做高数的网站

网站设置搜索框是什么知识点,有没有什么做高数的网站,网站流量导入是什么意思,建设企业网站的企业转载自 深入wepy源码#xff1a;wpy文件编译过程wepy 是腾讯开源的一款小程序框架#xff0c;主要通过预编译的手段#xff0c;让开发者采用类 Vue 风格开发。 让我们一起看看#xff0c; wepy 是如何实现预编译的。先放上一张官网的流程图#xff0c;后面的分析可以参考该…转载自 深入wepy源码wpy文件编译过程wepy 是腾讯开源的一款小程序框架主要通过预编译的手段让开发者采用类 Vue 风格开发。 让我们一起看看 wepy 是如何实现预编译的。先放上一张官网的流程图后面的分析可以参考该图。wepy-cli 主要负责 .wpy 文件的编译目录结构如下编译的入口是 src/compile.js 中的 compile() 方法该方法主要是根据文件类型执行不同的 compiler 比如 .wpy 文件会执行 compile-wpy.js 下的 compile() 方法。 compile(opath) {...switch(opath.ext) {  case ext:  cWpy.compile(opath);  break;  case .less:  cStyle.compile(less, opath);  break;  case .sass:  cStyle.compile(sass, opath);  break;  case .scss:  cStyle.compile(scss, opath);  break;  case .js:  cScript.compile(babel, null, js, opath);  break;  case .ts:  cScript.compile(typescript, null, ts, opath);  break;  default:  util.output(拷贝, path.join(opath.dir, opath.base)); ... } }   .wpy文件拆解compile-wpy.js 下的 compile() 方法核心调用了 resolveWpy() 方法。resolveWpy() 方法主要是将 .wpy 拆解成 rst 对象并对其中的 template、script 做一些预处理然后将 template、 script、 style 三部分移交给不同的 compiler 处理。 生成rst对象 通过 xmldom 获取 xml 对象然后遍历节点拆解为 rst对象。 import {DOMParser} from xmldom; export default {createParser (opath) {return new DOMParser({...})},...resolveWpy () {let xml this.createParser(opath).parseFromString(content);} } rst对象结构如下 let rst {moduleId: moduleId,style: [],template: {code: ,src: ,type: },script: {code: ,src: ,type: } }; 此外还对 template 做了如下一些预处理获取文件中的 import 放入 rst.template.components 中获取 props 和 events 放入 rst.script.code 中 compile-template compile-template.js 中的 compile() 方法根据 template 的 lang 值执行不同的 compiler 比如 wepy-compile-typescript 。编译完成后执行 compileXML 方法做了如下的操作 updateSlot 方法: 替换 slot 内容updateBind 方法: 在 {{}} 和 attr 上加入组件的前缀例如 {{width}} - {{$ComponentName$width}}把自定义的标签、指令转换为 wxml 语法例如 repeat forxxx indexidx itemxxx keyxxx/repeat !-- 转换为 -- block wx:forxxx wx:for-indexxxx wx:for-itemxxx wx:keyxxxx/block compile-style 依旧先是根据 lang 值先执行不同的 compiler 比如 wepy-compile-less 。编译完成后执行 src/style-compiler/scope.js 中的 scopedHandler() 方法处理 scoped。 import postcss from postcss; import scopeId from ./scope-id;export default function scopedHandler (id, content) {console.log(id is: , id)console.log(css content is: , content)return postcss([scopeId(id)]).process(content).then(function (result) {console.log(css result is: , result.css)return result.css}).catch((e) {return Promise.reject(e)}) } 这里主要是利用 add-id 的 postcss 插件插件源码可参考 src/style-compiler/scope-id.js。根据上面的代码打印出来的log如下最后会把 requires 由绝对路径替换为相对路径并在 wxss 中引入最终生成的 wxss 文件为 import ./../components/demo.wxss;Page{background:#F4F5F7} ...   compile-script 依旧先是根据 lang 值执行不同的 compiler。compiler 执行完之后判断是否是 npm 包如果不是依据不同的 type 类型加入 wepy 初始化的代码。 if (type ! npm) {if (type page || type app) {code code.replace(/exports\.default\s*\s*(\w);/ig, function (m, defaultExport) {if (defaultExport undefined) {return ;}if (type page) {let pagePath path.join(path.relative(appPath.dir, opath.dir), opath.name).replace(/\\/ig, /);return \nPage(require(wepy).default.$createPage(${defaultExport} , ${pagePath}));\n;} else {appPath opath;let appConfig JSON.stringify(config.appConfig || {});let appCode \nApp(require(wepy).default.$createApp(${defaultExport}, ${appConfig}));\n;if (config.cliLogs) {appCode require(\./_wepylogs.js\)\n;}return appCode;}});} } 接下来会执行 resolveDeps() 方法主要是处理 requires。根据 require 文件的类型拷贝至对应的目录再把 code 中的 require 代码替换为 相对路径。 处理好的 code 最终会写入 js 文件中文件存储路径会判断类型是否为 npm。 let target; if (type ! npm) {target util.getDistPath(opath, js); } else {code this.npmHack(opath, code);target path.join(npmPath, path.relative(opath.npm.modulePath, path.join(opath.dir, opath.base))); } plugin 根据上面的流程图可以看出所有的文件生成之前都会经过 Plugin 处理。先来看一下compiler 中是如何载入 Plugin 的。 let plg new loader.PluginHelper(config.plugins, {type: css,code: allContent,file: target,output (p) {util.output(p.action, p.file);},done (rst) {util.output(写入, rst.file);util.writeFile(target, rst.code);} }); 其中config.plugins 就是在 wepy.config.js 中定义的 plugins。让我们来看一下 PluginHelper 类是如何定义的。 class PluginHelper {constructor (plugins, op) {this.applyPlugin(0, op);return true;}applyPlugin (index, op) {let plg loadedPlugins[index];if (!plg) {op.done op.done(op);} else {op.next () {this.applyPlugin(index 1, op);};op.catch () {op.error op.error(op);};if (plg)plg.apply(op);}} } 在有多个插件的时候不断的调用 next()最后执行 done()。 编写plugin wxss 与 css 相比拓展了尺寸单位即引入了 rpx 单位。但是设计童鞋给到的设计稿单位一般为 px那现在我们就一起来编写一个可以将 px 转换为 rpx 的 wepy plugin。 从 PluginHelper 类的定义可以看出是调用了 plugin 中的 apply() 方法。另外只有 .wxss 中的 rpx 才需要转换所以会加一层判断如果不是 wxss 文件接着执行下一个 plugin。 rpx 转换为 px 的核心是使用了 postcss-px2units plugin。下面就是设计好的 wepy-plugin-px2units更多源码可参考 github 地址( https://github.com/yingye/wepy-plugin-px2units )。 import postcss from postcss; import px2units from postcss-px2units;export default class {constructor(c {}) {const def {filter: new RegExp(\.(wxss)$),config: {}};this.setting Object.assign({}, def, c);}apply (op) {let setting this.setting;if (!setting.filter.test(op.file)) {op.next();} else {op.output op.output({action: 变更,file: op.file});let prefixer postcss([ px2units(this.setting.config) ]);prefixer.process(op.code, { from: op.file }).then((result) {op.code result.css;op.next();}).catch(e {op.err e;op.catch();});}} } 最后 本文分析的源码以 wepy-cli1.7.1 版本为准更多信息可参考 wepy github (即 github 1.7.x 分支https://github.com/Tencent/wepy/tree/1.7.x )。另外文中有任何表述不清或不当的地方欢迎大家批评指正。
http://www.huolong8.cn/news/214405/

相关文章:

  • 网页制作官方网站尖叫直播
  • 虚拟主机如何建设多个网站wordpress term_group
  • 坪山网站建设哪家便宜四川企业网站模板步骤
  • 深圳专业网站建设网站备案包括哪些东西
  • wordpress总是跳出淘宝关键词分布中对seo有危害的
  • 备案的网站是公司吗肇庆seo外包
  • 成都多享网站建设公司简述建设网站的步骤6
  • 西安高校定制网站建设公司推荐影视小程序搭建教程
  • 在云服务器上搭建网站前端项目开发流程
  • 市网站开发公司东莞网站设计在哪里
  • asp网站建设 aws中国三大生产建设兵团
  • 住房和城乡建设部网站注册网站 建设在作用是什么
  • 网站自动秒收录工具西乡网站开发
  • 京东网站建设流程和结构图厦门公司注册代理
  • 排名好的徐州网站建设工商管理系统官网
  • 网站建设术语 英文wordpress博客500
  • 重庆知名网站建设公司网站怎么添加代码
  • 建设网站主机可以用吗邢台市天气预报
  • 网站开发课程设计报告东莞好的网站建设哪家好
  • 简要描述创建商务站点的商务视频模板免费下载网站
  • dw建设手机网站网络营销平台有哪些?
  • 展厅设计公司网站电子商务网站运营 需要确立
  • dedecms做网站怎么查看黄浦区未成年人思想道德建设网站
  • 公司网站建设的建议wordpress如何设置导航栏
  • 如何介绍网站模板下载重庆比较好的软件开发培训学校
  • 深圳建外贸网站360收录提交
  • 企业网站托管方案iis添加网站建设中
  • 涂料厂做网站有用吗门户网站建设管理情况自查报告
  • 重庆网站建制作图网
  • 文字游戏做的最好的网站怎么自己做彩票网站