Giter VIP home page Giter VIP logo

kbone's Introduction

kbone

kbone 是一个致力于微信小程序和 Web 端同构的解决方案。

简介

微信小程序的底层模型和 Web 端不同,我们想直接把 Web 端的代码挪到小程序环境内执行是不可能的。kbone 的诞生就是为了解决这个问题,它实现了一个适配器,在适配层里模拟出了浏览器环境,让 Web 端的代码可以不做什么改动便可运行在小程序里。

这里有个简单的代码片段https://developers.weixin.qq.com/s/R9Hm0Qm67Acd,可以使用开发者工具打开看看效果。

因为 kbone 是通过提供适配器的方式来实现同构,所以它的优势很明显:

  • 大部分流行的前端框架都能够在 kbone 上运行,比如 Vue、React、Preact 等。
  • 支持更为完整的前端框架特性,因为 kbone 不会对框架底层进行删改(比如 Vue 中的 v-html 指令、Vue-router 插件)。
  • 提供了常用的 dom/bom 接口,让用户代码无需做太大改动便可从 Web 端迁移到小程序端。
  • 在小程序端运行时,仍然可以使用小程序本身的特性(比如像 live-player 内置组件、分包功能)。
  • 提供了一些 Dom 扩展接口,让一些无法完美兼容到小程序端的接口也有替代使用方案(比如 getComputedStyle 接口)。

使用

为了可以让开发者可以更自由地进行项目的搭建,以下提供了三种方式,任选其一即可:

使用 kbone-cli 快速开发

对于新项目,可以使用 kbone-cli 来创建项目,首先安装 kbone-cli:

npm install -g kbone-cli

创建项目:

kbone init my-app

进入项目,按照 README.md 的指引进行开发:

// 开发小程序端
npm run mp

// 开发 Web 端
npm run web

// 构建 Web 端
npm run build

PS:项目基于 webpack 构建,关于 webpack 方面的配置可以点此查看,而关于小程序构建相关的详细配置细节可以参考此文档

使用模板快速开发

除了使用 kbone-cli 外,也可以直接将现有模板 clone 下来,然后在模板基础上进行开发改造:

项目 clone 下来后,按照项目中 README.md 的指引进行开发。

手动配置开发

此方案基于 webpack 构建实现,如果你不想要使用官方提供的模板,想要更灵活地搭建自己的项目,又或者是想对已有的项目进行改造,则需要自己补充对应配置来实现 kbone 项目的构建。

一般需要补充两个配置:

点此可以查看具体配置方式和操作流程。

kbone-ui

kbone-ui 是一个能同时支持 小程序(kbone) 和 vue 框架开发的多端 UI 库。

  • 即可以基于 kbone 同时开发小程序和 H5,也可以单独使用开发 H5 应用。
  • 支持以 Vue 语法来支持 H5 端和小程序端运行
  • 对齐 微信weui 样式组件

文档

更为详细的说明和指引,可点击查看文档

PS:如果文档无法访问,可尝试访问备份文档镜像

问题

此方案虽然将整个 Web 端框架包含进来并提供了适配层,但是也不是银弹,无法满足所有场景,具体限制可参考问题文档。如果还遇到其他问题,可在 issue 中反馈。

选择

业内其实已经出现了很多关于同构的解决方案了,每个方案都有自己的优劣,不存在能够完美解决所有问题的方案。kbone 也一样,它的优势在上面提到过,而它的不足也是它的实现原理带来的。kbone 是使用一定的性能损耗来换取更为全面的 Web 端特性支持。

所以关于性能方面,如果你对小程序的性能特别苛刻,建议直接使用原生小程序开发;如果你的页面节点数量特别多(通常在 1000 节点以上),同时还要保证在节点数无限上涨时仍然有稳定的渲染性能的话,可以尝试一下业内采用静态模板转译的方案;其他情况就可以直接采用 kbone 了。

贡献者

感谢你们

查看代码贡献规范

交流

QQ 交流群:926335938

使用相关问题可在 Kbone社区 发帖

案例

微信开放社区

License

MIT

kbone's People

Contributors

bobby169 avatar dntzhang avatar hedgehogking avatar jayjliang avatar jimmyvv avatar juneandgreen avatar stephenml avatar sunoj avatar tidyzq avatar wechat-miniprogram-admin avatar yangyongan avatar yiliang114 avatar z1hgq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kbone's Issues

Preact X

Preact v10.0.0 已经正式发布了,kbone 可以支持 preact x 了吗?

bug

<div style="width: 50px;box-sizing: border-box;border: 1px red solid;font-size: 16px;height: 26px;padding: 4px 4px;line-height: 1">123</div>

真机样式和开发者工具/web 样式不一样

使用自定义组件进行递归的天坑

突然发现,和 fard 是类似的思路
同样为了递归,使用了自定义组件,以下是 fard 遇到的问题:

  1. 自定义组件递归,每个组件都是shadow-dom,导致 css 穿透困难,更有 flex 等很多对层级有要求的很多用法无法很好的生效
  2. 控制台调试非常丑
  3. 每个 dom 节点上的事件等,都和组件挂钩,不方便也不科学

而且我们经过性能测试,比微信原生甚至 template 差

我提了一个需求给微信小程序社区,如果他们支持 template 的递归,就可以不使用自定义组件了
然而现在看来,应该是被无视掉了,唉

楼主怎么看,反正目前来说,自定义组件的递归可以说是不那么容易接受的

canvas 初始化节点获取不到

 <canvas id="canvas" style="width: 100%; height: 100%; position: absolute" type="2d"></canvas>

    wx.createSelectorQuery()
      .select('#canvas')
      .fields({
        node: true,
        size: true
      })
      .exec(function (res) { self.initCanvas(res) })

Cannot set property behavior of #<WxComponent> which has only a getter

preact+typescript,使用小程序内置组件时报错。

用法:

<wx-switch />
<wx-component behavior="picker" mode="region">选择城市</wx-component>

报错:

VM1845:1 thirdScriptError
Cannot set property behavior of #<WxComponent> which has only a getter;at "pages/index/index" page lifeCycleMethod onLoad function
TypeError: Cannot set property behavior of #<WxComponent> which has only a getter

[Bug Report] Error: Component is not found in path "pages/home/miniprogram-element" (using by "pages/home/index")

VM271:1 Error: Component is not found in path "pages/home/miniprogram-element" (using by "pages/home/index")
    at K (WAService.js:1)
    at K (WAService.js:1)
    at WAService.js:1
    at Module.Fe (WAService.js:1)
    at Function.value (WAService.js:1)
    at Et (WAService.js:1)
    at o (WAService.js:1)
    at WAService.js:1
    at WAService.js:1
    at WAService.js:1
  1. 使用脚手架进行初始化 kbone init my-app(vue) && yarn && npm run mp
  2. 遇到 #4 里面的问题,通过安装 cd dist/mp && npm install --save miniprogram-render 模块 && 构建 npm && 编译 解决
  3. 但是会出现上面的问题,通过 Google 进行了搜索,没有找到合适的回答,所以想麻烦作者,帮忙看下,非常感谢。

附上截图,再次感谢

image

ReferenceError: Event is not defined

你好,我们项目编译之后允行报错。

vendorshome.js:2 Uncaught (in promise) ReferenceError: Event is not defined
at new s (vendors
home.js:2)
at Function.s.attach (vendorshome.js:2)
at home.js:1
at c (vendors
home.js:2)
at Generator._invoke (vendorshome.js:2)
at Generator.forEach.t. [as next] (vendors
home.js:2)
at c (vendorshome.js:2)
at e (vendors
home.js:2)
at vendors~home.js:2
at new Promise ()

使用<canvas>绘制不出东西

<canvas class="progress" canvas-id="canvasProgress"></canvas>

 const ctx =  wx.createCanvasContext('canvasProgress');
context.setStrokeStyle("#00ff00")
context.setLineWidth(5)
context.rect(0, 0, 200, 200)
context.stroke()
context.setStrokeStyle("#ff0000")
context.setLineWidth(2)
context.moveTo(160, 100)
context.arc(100, 100, 60, 0, 2 * Math.PI, true)
context.moveTo(140, 100)
context.arc(100, 100, 40, 0, Math.PI, false)
context.moveTo(85, 80)
context.arc(80, 80, 5, 0, 2 * Math.PI, true)
context.moveTo(125, 80)
context.arc(120, 80, 5, 0, 2 * Math.PI, true)
context.stroke()
context.draw()

vue+kbone如何适配微信H5和小程序?

你好,你在研究vue+kbone中是如何做手机微信H5和小程序适配的?我之前采用的是微信H5用flexible+px转rem适配的,小程序是750rpx做的。现在有什么方法vue+kbone构建H5和小程序中,两者样式都能够正常显示?

运行demo1报错


/Users/aymonyu/tencent/test/kbone/examples/demo1/node_modules/webpack-cli/bin/cli.js:93
                                throw err;
                                ^

Error: Cannot find module 'webpack-sources'
```
npm i webpack-sources -S
还是报错

支持支付宝、百度等平台吗?

一般来说,开发小程序,肯定希望一次写码,简单处理之后,就可以编译到多端去用,这应该也是商家的一个期望,不知道 kbone 是否支持微信之外的其他小程序平台?

自动收集原生自定义组件的 props 和 events

现在使用自定义组件必须通过 webpack 配置来完成:

wxCustomComponent: {
	root: path.join(__dirname, '../src/custom-components'),
	usingComponents: {
		'comp-a': {
			path: 'comp-a',
			props: ['prefix', 'suffix'],
			events: ['someevent'],
		},
		'comp-b': {
			path: 'comp-b/index',
			props: ['prefix'],
		},
		'comp-c': 'comp-c',
	},
},

这样引用第三方小程序 UI 库太费劲了。

能不能支持自动收集组件的 propsevents, 只声明组件的的名称和路径?
或者更友好地直接作为 VueReact 组件引用, 而无需申明 useComponents

import CustomizedComp from 'thirdparty/weapp-ui/comp'; 

how to minify generated files?

在 optimization.minimizer 中使用 TerserJSPlugin OptimizeCSSAssetsPlugin 进行压缩,common 文件夹下面的 main.js 等都进行了压缩,但是插件生成的 app.js pages/index.wxss 这些都没有压缩,请问应该怎么处理?

i18n support

hey,

firstly this is a great framework!

I'd like to query about i18n support. eg. can vue-i18n be used then auto converted to miniprogram-i18n compatible? what's the road map? or what's the recommended way?

thanks in advance!

在 React + Kbone 模板中引入 Material-UI 组件小程序端报错

在 React + Kbone 模板中引入 Material-UI 的组件后,小程序端报了以下错误。这还有救吗?

Cannot read property 'appendChild' of null;at "pages/index/index" page lifeCycleMethod onLoad function
TypeError: Cannot read property 'appendChild' of null
    at insertStyle (http://127.0.0.1:64232/appservice/common/vendors~index.js:2206:12)
    at DomRenderer.attach (http://127.0.0.1:64232/appservice/common/vendors~index.js:2291:5)
    at StyleSheet.attach (http://127.0.0.1:64232/appservice/common/vendors~index.js:1563:38)
    at attach (http://127.0.0.1:64232/appservice/common/vendors~index.js:4491:19)
    at http://127.0.0.1:64232/appservice/common/vendors~index.js:4625:7
    at useSynchronousEffect (http://127.0.0.1:64232/appservice/common/vendors~index.js:4578:14)
    at http://127.0.0.1:64232/appservice/common/vendors~index.js:4617:5
    at WithStyles (http://127.0.0.1:64232/appservice/common/vendors~index.js:4709:21)
    at Ih (http://127.0.0.1:64232/appservice/common/vendors~index~log.js:339:98)
    at ni (http://127.0.0.1:64232/appservice/common/vendors~index~log.js:357:192)

查看 vendors~index.js 发现:

/**
 * Gets the `head` element upon the first call and caches it.
 * We assume it can't be null.
 */
var getHead = memoize(function () {
  // 这里返回的是 null, 从而导致 insertStyle 的时候 getHead().appendChild(style) 报错
  return document.querySelector('head');  
});

另外, 开发者工具显示以下 Warning:

VM151:1 window.getComputedStyle is not supported, please use window.$$getComputedStyle instead of it

window.getComputedStyle更改为window.$$getComputedStyle后,报错:

window.js:215 Uncaught (in promise) TypeError: _this3.$$createSelectorQuery is not a function
    at window.js:215
    at new Promise (<anonymous>)
    at Window.$$getComputedStyle (window.js:211)
    at Object.<anonymous> (vendors~index.js:3948)
    at __webpack_require__ (index.js:81)
    at Module.21 (index.js:188)
    at __webpack_require__ (index.js:81)
    at checkDeferredModules (index.js:47)
    at index.js:154
    at module.exports (index.js:157)

使用alloyFinger长按手势,触发事件时由于touches为null引起length属性读取报错

在浏览器中e.touches返回的是一个类数组对象,始终有length属性。
由于miniprogram-render中Event类进行了如下处理:

this.$_touches = null
...
if (options.touches && options.touches.length) {

        this.$_touches = options.touches.map(touch => ({...touch, target: options.target}))

        this.$$checkTargetTouches()
}

很明显当touches长度为0时 this.$_touches 不会被处理成一个空数组。
changedTouches、 targetTouches可能也有类似情况,希望可以做出相关修改,避免冲突。

Perfomance issue

发现一个性能问题,在使用 translate 和 scale 配合 window.requestAnimationFrame 开发动画的过程中, CPU 占用高达 90%

  1. 模拟器 CPU 占用高达 90%,但效果尚可接受
  2. iOS 有严重掉帧
  3. Android 卡顿非常严重,不可用

复现

index.js

import React from 'react'
import ReactDOM from 'react-dom'
import Counter from './components/counter'
import Anmie from './anmie';
export default function createApp() {
  const container = document.createElement('div')
  container.id = 'app'
  document.body.appendChild(container)

  ReactDOM.render(<div style={{ position: "relative" }}>
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />
    <Anmie step={20} />


  </div>, container)
}

"undefined" != typeof wx && wx.getSystemInfoSync || createApp()

anmie.js

import React from 'react'
import ReactDOM from 'react-dom'
import { number } from 'prop-types'
export default class Anmie extends React.Component {
    constructor(props) {
        super(props);
        this.max = 300;
        this.index = 0;
        this.asc = true;
        this.state = {
            x: 0,
            y: 0
        }
    }

    componentDidMount() {
        window.requestAnimationFrame(this.anmie.bind(this));
        // window.setTimeout(this.anmie.bind(this), 100);
    }

    anmie() {
        if (this.index === this.max) {
            this.asc = false;
        }
        if (this.index === 0) {
            this.asc = true;
        }
        if (this.asc) {

            this.index = this.index + this.props.step;
        } else {
            this.index = this.index - this.props.step;
        }
        this.setState({
            x: this.index,
            y: this.index - 5,
        })
        // window.setTimeout(this.anmie.bind(this), 100);
        window.requestAnimationFrame(this.anmie.bind(this));
    }

    render() {
        return <div style={{ transform: `translate(${this.state.x}px, ${this.state.y}px)`, position: "absolute", width: `100px`, height: `100px`, backgroundColor: "black" }}></div>
    }
}

Function(...) is not a function

综合了一下demo1和demo4 运行正常,然后我在项目中封装了个axios,小程序端构建npm后报这个错,请问怎么修改?还是我哪里用的有问题,,,

关于UI组件库

比如vant本身有小程序和web端的版本,能否兼容小程序直接去找vant的小程序版本, web端找vant的web版本?

dist/mp/node_modules 应该是多余的?

image

miniprogram-element、miniprogram-render 已经随着 miniprogram_npm 目录一起放到了dist/mp 目录下,node_modules 应该就不需要放进去了(我测试了一下,直接删除 dist/mp/node_modules 目录,运行正常)。

这个是否可以删除?感觉挺影响性能的。

React checkbox onChange 事件没响应

利用 https://github.com/wechat-miniprogram/kbone-template-react 模板
把修改以下代码就可以复现,捕获不了 onChange 事件

// src/index.js
import React from 'react'
import ReactDOM from 'react-dom'

function onChange() {
  console.log('onChange')
}

export default function createApp() {
  const container = document.createElement('div')
  container.id = 'app'
  document.body.appendChild(container)

  ReactDOM.render(<label>
    <input
      type="checkbox"
      onChange={onChange}
    />
    这是 checkbox 组件
  </label>, container)
}

!process.env.isMiniprogram && createApp()

支付等原生sdk该怎么用

假如用kbone开发小程序,当我有支付之类的业务逻辑该怎处理?在vue中调h5支付还是直接调小程序支付?

被miniprogram-element 包裹的内容无法被 createSelectorQuery select到

示例代码

      window.$$createSelectorQuery().select('.h5-body').boundingClientRect((rect) => {
        // 可以
      }).exec()

      window.$$createSelectorQuery().select('#app').boundingClientRect((rect) => {
        // rect 是null
      }).exec()

wxml结构
image

不管是用wx.createSelectorQuery 还是 window.$$createSelectorQuery 结果都是一样

使用内置组件写起来很不舒服

开始使用的时候,觉得内置组件写起来很不舒服。
目前我在开发小程序,每次我在写html/wxml标签的时候,我都会在想,我写的这个标签会不会被转化为其他标签?比如我写span,会不会被渲染为text组件。我写img,会不会被渲染为image。这个时候我就得查一下开发指南看一遍。
既然不确定,那我就统一写wx-component吧。
可是又没有类型提示。我不知道behavior有哪些选项。填了behavior后,能传的属性值、方法名也没有代码提示。写起来就很难受。
想看下这里有没有什么比较好的解决方案?

Syntax Error: SyntaxError: Unexpected token

您好,请教一个问题,我的场景略微有些特殊,容我描述一下:

  1. 本地有两个项目:kbone-template-vue(kbone提供的vue 小程序模板) 和 本地的 vue-cli3 生成的项目abc-repo(jsx 语法)

  2. 我想让 vue-cli3 构建一个 library ,叫 abc-lib(本地构建为abc-lib.umd.js)

需求介绍

如果想在 kbone的项目(小程序)中通过 import abc from 'abc-lib的entry 的绝对路径的形式引入(一般为 main.js)', 在 home 页面中将其引入,并作为一个组件使用(引入本地路径的原因是,我想本地开发没有问题之后,再发布 npm 包)

我的尝试

  1. 我尝试了下,如果入口是 abc-lib-main.vue, 在 jbone的模板项目中的 home.vue 通过
import AbcLib from '/Users/lambert/Documents/Code/abc-repo/src/abc-lib-main.vue

内容是可以正常渲染的,没有问题的,abc-lib-main.vue 内容如下:

<template>
  <div>
    render engine for app
  </div>
</template>

<script>
export default {

}
</script>
  1. 但是,如果我把上面的内容改一下,入口由 abc-lib-main.vue 改为 abc-lib-main.js, 在 kbone的模板项目中的 home.vue 通过
import AbcLib from '/Users/lambert/Documents/Code/abc-repo/src/abc-lib-main.js

就会报错了,其中 abc-lib-main.js 内容如下

<template>
  <div>
    render engine for app
  </div>
</template>

<script>
export default {

}
</script>

报错信息

94% after seal

 ERROR  Failed to compile with 1 errors                                                    1:16:28 PM

 error  in /Users/lambert/Documents/Code/abc-repo/src/abc-lib-main.js

Syntax Error: SyntaxError: Unexpected token (9:11)

   7 |   },
   8 |   render (h) {
>  9 |     return <div>render engine for app</div>
     |            ^
  10 |   }
  11 | }
  12 |



 @ ./node_modules/babel-loader/lib!./node_modules/thread-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/home/Index.vue?vue&type=script&lang=js& 39:0-109 48:12-18
 @ ./src/home/Index.vue?vue&type=script&lang=js&
 @ ./src/home/Index.vue
 @ ./src/router/index.js
 @ ./src/main.js

为何采用 jsx 的写法,而不是vue 写法:
是因为 abc-lib 采用jsx 语法已经开发比较成熟了,改起来成本略高

我尝试了改了 webpack 的js的loader 对应的配置,但仍然无法生效,还想请作者指点一下,非常感谢。

我看 .babelrc 的配置中已经包含了 babel-plugin-transform-vue-jsx 了

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-vue-jsx", "transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
    }
  }
}

webpack.mp.config.js

// js
      {
        test: /\.js$/,
        use: [
          'thread-loader',
          {
            loader: 'babel-loader',
            options: {
              cacheDirectory: true,
            }
          }
        ],
        exclude: /node_modules/
      },

$$getNodesRef() 获取不到canvas 实例

<canvas canvas-id="source" id="source"></canvas>

            document.querySelector('#source').$$getNodesRef().then(nodesRef => {
                nodesRef.node(res => {
                   console.log(res.node);  // 这里res.node == null
                }).exec()
            })

$parseInt is not a function ; 压缩后报错 thirdScriptError: r is not a function;at "pages/main/index" page lifeCycleMethod onLoad function

20191127体验有几点疑问

背景

已用自制简易脚手架做了多款小程序,从简单到复杂都有。
而由于工作性质,H5到小程序切来切去开发,感觉不是很智能,希望可以同一开发方式

所以,打算体验一下kbone能否解决需求

首先,已经排除掉其他什么静态编译的脚手架,毕竟坑多还不如原生,没必要。而kbone的方法,我的理解是模拟一些小程序不支持的模块来实现可以运行在小程序上

刚刚,体验了一下手动webpack和Demo1 & Demo5,感觉脑海里有一些疑问,想先来讨论一下。

第一个情况:全局数据共享?

由于一般我们是用单页开发H5,所以全局数据共享很简单。
但是小程序是多页开发,该怎么办?

这点现在有点头疼,按照以前的实现方式就是保存页面实例然后刷新,但是这个方法只试用于小程序,不适用于H5。

也想不到更好的方案,更不能不用,因为现在小程序越做越复杂,没有全局数据共享不太科学

第二个情况:什么情况下使用单页?

感觉这点有点鸡肋,什么小程序下在一个页面里是单页应用?如果真的单页为什么不直接上webview?
更不用说什么vuex、router完全用不上

大部分情况下,大家都想要的是app的体验效果,即点击左滑进入的效果

而且,如果是多页的,感觉失去了使用的意义,因为所有东西还是分离的,纯粹只是换种写法写一个页面而已,而不是写一个应用

第三个情况:每个页面加载一次vue?

和上面两个问题一样,按照现在的方式,进入一个页面就要加载一次vue及其他依赖,可能应该列表页都要,也不是很科学


写到现在,感觉自己的问题在于「如何能够在小程序端实现单页的开发模式」,这一点确实也和kbone没啥关系...

不知道大家是怎么使用的?和如何解决全局数据共享问题

偶尔出现Uncaught Error: module "pages/index/miniprogram-render.js" is not defined

Uncaught Error: module "pages/index/miniprogram-render.js" is not defined
    at require (VM956 WAService.js:19)
    at VM956 WAService.js:19
    at index.js:1
    at require (VM956 WAService.js:19)
    at <anonymous>:11:7
    at HTMLScriptElement.scriptLoaded (appservice?t=1564448406408:2221)
    at HTMLScriptElement.script.onload (appservice?t=1564448406408:2233)

编译运行时出现了这个错误

cover-view 里面的button 真机上渲染异常

<cover-view class="auth-user-dialog" v-if="isShowDialog">
    <cover-view class="dialog-content">
        <cover-view class="dialog-center">
            <cover-view class="dialog-title">登录提醒</cover-view>
            <cover-view class="dialog-desc">登录后才可以正常使用功能</cover-view>
        </cover-view>
        <cover-view class="dialog-btns">
            <button class="dialog-btn dialog-cancel" @click="cancelLogin">暂不登录</button>
            <button class="dialog-btn dialog-confirm" open-type="getUserInfo" @getuserinfo="onGotUserInfoBeforeBind" @error="onAuthError">立即登录</button>
        </cover-view>
    </cover-view>
</cover-view>
.auth-user-dialog {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, .3);

    .dialog-content {
        position: absolute;
        width: 80%;
        top: 30%;
        left: 10%;
        background: #FFF;
        border-radius: 4px;
    }
    .dialog-btns {
        display: block;
        border-top: 1px solid #e5e5e5;
        position: relative;
        z-index: 999999;
    }
    .dialog-btn {
        width: 50%;
        display: inline-block;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        position: relative;
        z-index: 999999;
    }
}

在模拟器上
image

在真机上
image

可以看到,button其实是把内容撑开了,但是按钮文案并没有显示

另外:因为是从mpvue的项目迁移过来的,相同的代码在使用mpvue的时候并没有问题,猜测大概率还是因为kbone在渲染每一个内置的组件时都会包一个element引起的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.