Write it up front
Q: Why did you write this article?
A: The summary after the actual combat project is A good way to learn.
Q: Why Kbone instead of Taro?
A: Kbone is officially launched by wechat hahaha.
Q: Why not directly use wechat small program native development?
A: Because of the Kbone cross-platform tool, plus the React itself. If you use wechat small program native development needs to learn the cost (mainly stupid & lazy)!
Quick access to
- Kbone development documentation
- Kbone Github
- Applets development documentation
- Wechat public platform
Kbone + React Applet building process
kbone init my-app
chooseReact
npm run mp
- Wechat developer toolsnewSmall program.directoryPoint to the
kbone
的my-app/build/mp
Kbone
的 React
Project template
- The official offer is direct
Clone
Use them -React Project Template - Their development
my-app/src/index.js
import React from 'react' import ReactDOM from 'react-dom' import App from './App' export default function createApp() { const container = document.createElement('div') container.id = 'app' document.body.appendChild(container) ReactDOM.render(<App />, container) } "undefined" ! = typeof wx && wx.getSystemInfoSync || createApp()Copy the code
- Component development and tradition
React
The same
Less
support
Kbone’s React project does not support Sass by default, and I failed to set Sass several times. Always decide to use Less.
- in
webpack.mp.config.js
The originalcss
replace{ test: /.less$/, use: [ MiniCssExtractPlugin.loader, 'css-loader', { loader: 'less-loader', }, ], }, Copy the code
kbone
Configure the applet parameters
Scripts/miniprogram. Config. Js every change need to NPM run mp
module.exports = { redirect: { notFound: 'index', accessDenied: 'index', }, generate: { autoBuildNpm: 'npm', }, app: {navigationBarTitleText: 'small program title, backgroundColor:' # d23836 ', / / navigationBarBackgroundColor page background color: NavigationStyle :'custom',// Unrealistic top bar full screen page}, appExtraConfig: {sitemapLocation: 'sitemap.json',}, global: {pageBackgroundColor: '#d23836',// share: false,// default to disable sharing}, pages: {}, optimization: { domSubTreeLevel: 10, elementMultiplexing: true, textMultiplexing: true, commentMultiplexing: true, domExtendMultiplexing: true, styleValueReduce: 5000, attrValueReduce: 5000, }, projectConfig: { projectname: 'Applets project name ', appID:' Applets development AppID ',},}Copy the code
Kbone
+ React
Summary of potholes encountered in use
- Does not support
id
Selectors define styles - Does not support
button[disabled]
Selectors define styles img
The image cannot be set to full screen height, for example:height:100vh
- Does not support
lucky-canvas
的React
Original version - delete
src/log.js
After, remember inscripts/webpack.mp.config.js
In the deletelog: path.resolve(__dirname, '.. /src/log.js')
The little program thing
- The first submission of the mini-program will be filled in
*** Applets privacy protection boot
, carefully and truthfully fill in actively (experienced - A public account can be associated (authentication to
300
) or register (certified public account registration free?) - Their current submission of small procedures audit feel quite fast, may not be complex content of the relationship
Continuously updated