How to use the miniprogram-render.$$adapter function in miniprogram-render

To help you get started, we’ve selected a few miniprogram-render examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tencent / omi / packages / preact-kbone / build / mp / pages / index / index.js View on Github external
function dealWithPage(evt, window, value) {
    const type = evt.type
    let url = evt.url

    if (value === 'webview') {
        // 补全 url
        url = mp.$$adapter.tool.completeURL(url, window.location.origin)

        const options = {url: `/pages/webview/index?url=${encodeURIComponent(url)}`}
        if (type === 'jump') wx.redirectTo(options)
        else if (type === 'open') wx.navigateTo(options)
    } else if (value === 'error') {
        console.error(`page not found: ${evt.url}`)
    } else if (value !== 'none') {
        const targeturl = `${window.location.origin}/redirect?url=${encodeURIComponent(url)}`
        const options = {url: `/pages/${value}/index?type=${type}&targeturl=${encodeURIComponent(targeturl)}`}
        if (window.$$miniprogram.isTabBarPage(`/pages/${value}/index`)) wx.switchTab(options)
        else if (type === 'jump') wx.redirectTo(options)
        else if (type === 'open') wx.navigateTo(options)
    }
}
github Tencent / omi / packages / omis-kbone / build / mp / miniprogram_npm / miniprogram-element / util / init-handle.js View on Github external
const mp = require('miniprogram-render')
const _ = require('./tool')
const component = require('./component')

const {
    Event,
} = mp.$$adapter
const {
    WX_COMP_NAME_MAP,
    NOT_SUPPORT,
} = _

module.exports = {
    /**
     * 初始化
     */
    init(data) {
        const domNode = this.domNode
        const tagName = domNode.tagName

        if (tagName === 'WX-COMPONENT') {
            // 无可替换 html 标签
            data.wxCompName = domNode.$$behavior
github wechat-miniprogram / kbone / packages / miniprogram-element / src / index.js View on Github external
const mp = require('miniprogram-render')
const _ = require('./util/tool')
const initHandle = require('./util/init-handle')
const component = require('./util/component')

const {
    cache,
    EventTarget,
    tool,
} = mp.$$adapter
const {
    NOT_SUPPORT,
} = _
const {
    wxCompNameMap,
} = component

// dom 子树作为自定义组件渲染的层级数
const MAX_DOM_SUB_TREE_LEVEL = 10
let DOM_SUB_TREE_LEVEL = 10

Component({
    properties: {
        inCover: {
            type: Boolean,
            value: false,
github Tencent / omi / packages / omi-kbone / build / mp / miniprogram_npm / miniprogram-element / index.js View on Github external
const mp = require('miniprogram-render')
const _ = require('./util/tool')
const initHandle = require('./util/init-handle')

const {
    cache,
    EventTarget,
    tool,
} = mp.$$adapter
const {
    WX_COMP_NAME_MAP,
    NOT_SUPPORT,
} = _

// dom 子树作为自定义组件渲染的层级数
const MAX_DOM_SUB_TREE_LEVEL = 10
let DOM_SUB_TREE_LEVEL = 10

Component({
    properties: {
        inCover: {
            type: Boolean,
            value: false,
        },
    },
github Tencent / omi / packages / omi-kbone / build / mp / miniprogram_npm / miniprogram-element / index.js View on Github external
const mp = require('miniprogram-render')
const _ = require('./util/tool')
const initHandle = require('./util/init-handle')

const {
    cache,
    EventTarget,
    tool,
} = mp.$$adapter
const {
    WX_COMP_NAME_MAP,
    NOT_SUPPORT,
} = _

// dom 子树作为自定义组件渲染的层级数
const MAX_DOM_SUB_TREE_LEVEL = 10
let DOM_SUB_TREE_LEVEL = 10

Component({
    properties: {
        inCover: {
            type: Boolean,
            value: false,
        },
    },
github wechat-miniprogram / kbone / packages / miniprogram-element / src / util / init-handle.js View on Github external
const mp = require('miniprogram-render')
const _ = require('./tool')
const component = require('./component')

const {
    Event,
} = mp.$$adapter
const {
    NOT_SUPPORT,
} = _
const {
    wxCompNameMap,
    handles,
} = component

module.exports = {
    /**
     * 初始化
     */
    init(data) {
        const domNode = this.domNode
        const tagName = domNode.tagName
github Tencent / omi / packages / omis-kbone / build / mp / miniprogram_npm / miniprogram-element / component / input.js View on Github external
const mp = require('miniprogram-render')

const {
    cache,
} = mp.$$adapter

/**
 * https://developers.weixin.qq.com/miniprogram/dev/component/input.html
 */
module.exports = {
    properties: [{
        name: 'value',
        get(domNode) {
            return domNode.value || ''
        },
    }, {
        name: 'type',
        get(domNode) {
            const value = domNode.type || 'text'
            return value !== 'password' ? value : 'text'
        },
github Tencent / omi / packages / omi-kbone / build / mp / miniprogram_npm / miniprogram-element / component / image.js View on Github external
const mp = require('miniprogram-render')

const {
    cache,
    tool,
} = mp.$$adapter

/**
 * https://developers.weixin.qq.com/miniprogram/dev/component/image.html
 */
module.exports = {
    properties: [{
        name: 'renderingMode',
        get(domNode) {
            return domNode.getAttribute('rendering-mode') || ''
        },
    }, {
        name: 'src',
        get(domNode) {
            const window = cache.getWindow(domNode.$$pageId)
            return domNode.src ? tool.completeURL(domNode.src, window.location.origin, true) : ''
        },
github Tencent / omi / packages / omi-kbone / build / mp / miniprogram_npm / miniprogram-element / component / cover-image.js View on Github external
const mp = require('miniprogram-render')

const {
    cache,
    tool,
} = mp.$$adapter

/**
 * https://developers.weixin.qq.com/miniprogram/dev/component/cover-image.html
 */
module.exports = {
    properties: [{
        name: 'src',
        get(domNode) {
            const window = cache.getWindow(domNode.$$pageId)
            return domNode.src ? tool.completeURL(domNode.src, window.location.origin, true) : ''
        },
    }],
    handles: {
        onCoverImageLoad(evt) {
            this.callSimpleEvent('load', evt)
        },
github alibaba / rax / packages / miniapp-element / src / component / image.js View on Github external
const mp = require('miniprogram-render');

const {
  cache,
  tool,
} = mp.$$adapter;

/**
 * https://developers.weixin.qq.com/miniprogram/dev/component/image.html
 */
export default {
  PROPS: [{
    name: 'renderingMode',
    get(domNode) {
      return domNode.getAttribute('rendering-mode') || '';
    },
  }, {
    name: 'src',
    get(domNode) {
      const window = cache.getWindow(domNode.$$pageId);
      return domNode.src ? tool.completeURL(domNode.src, window.location.origin, true) : '';
    },

miniprogram-render

web's adapter for miniprogram

MIT
Latest version published 10 months ago

Package Health Score

70 / 100
Full package analysis

Similar packages