|
本帖最后由 周大胖子 于 2021-3-2 16:45 编辑
先上个官方文档链接:https://remaxjs.org/guide/basic/custom-component [我就是照着这个做的 然后满世界报错]
好了 先谈成功方法:
1.在项目中安装微信组件的包 :
npm install --save weui-miniprogram
2.引入且使用【可以照着上方的链接里面复制,也可以复制我下面的】
- import * as React from 'react';
- import { View , Button } from 'remax/one';
- import Cells from "weui-miniprogram/miniprogram_dist/cells/cells";
- import Cell from 'weui-miniprogram/miniprogram_dist/cell/cell';
- import 'weui-miniprogram/miniprogram_dist/weui-wxss/dist/style/weui.wxss';
- import Dialog from 'weui-miniprogram/miniprogram_dist/dialog/dialog';
- class Trademark extends React.Component{
- constructor(props) {
- super(props);
- this.tapDialogButton = this.tapDialogButton.bind(this);
- this.doDialog = this.doDialog.bind(this);
- this.state={
- dialogShow: false,
- showOneButtonDialog: false,
- buttons: [{text: '取消'}, {text: '确定'}],
- }
- }
- tapDialogButton(e)
- {
- console.log(e)
- this.setState({
- dialogShow: false
- })
- }
- doDialog(){
- console.log('进来了')
- this.setState({
- dialogShow: true
- })
- }
- // 坑爹 官方文件复制粘贴过来后 凉了,且各种实验 都不行 除非删了重新解压缩
- render(){
- return(
- <View className="textH3">
- 商标
- <Button className="tmListBtn"> 商标注册1</Button>
- <Button className="tmListBtn"> 商标注册2</Button>
- <Button className="tmListBtn"> 商标注册3</Button>
- <View>
- <Cells title="带说明的列表项">
- <Cell value="标题文字" footer="说明文字"></Cell>
- <Cell>
- <View>标题文字(使用slot)</View>
- <View slot="footer">说明文字</View>
- </Cell>
- </Cells>
- </View>
-
- <Button className="tmListBtn" onTap={this.doDialog} > 弹出框测试 </Button>
- <Dialog title="test" show={this.state.dialogShow} bindbuttontap={this.tapDialogButton} buttons={this.state.buttons}>
- <View> 弹出框 </View>
- </Dialog>
- </View>
- );
- }
- }
- export default Trademark;
复制代码
3.关掉cmd, 把dist 文件夹删了[嗯 没错 删掉] ,然后 重新打包 npm run dev wechat
4. 进微信开发者工具里面看效果:
没报错很好结束,如果报错:
[] ENOENT: no such file or directory, open 'E:\phpstudy_pro\remax\here\dist\wechat\project.config.json'
Error: ENOENT: no such file or directory, open 'E:\phpstudy_pro\remax\here\dist\wechat\project.config.json'
出现这个解决方法:
在 dist/wecaht 文件夹内新建一个【 project.config.json 】 就这个文件,里面内容可以复制下面的:
- {
- "description": "项目配置文件",
- "packOptions": {
- "ignore": []
- },
- "setting": {
- "urlCheck": false,
- "es6": true,
- "enhance": false,
- "postcss": true,
- "preloadBackgroundData": false,
- "minified": true,
- "newFeature": false,
- "coverView": true,
- "nodeModules": false,
- "autoAudits": false,
- "showShadowRootInWxmlPanel": true,
- "scopeDataCheck": false,
- "uglifyFileName": false,
- "checkInvalidKey": true,
- "checkSiteMap": true,
- "uploadWithSourceMap": true,
- "compileHotReLoad": false,
- "useMultiFrameRuntime": true,
- "useApiHook": true,
- "useApiHostProcess": false,
- "babelSetting": {
- "ignore": [],
- "disablePlugins": [],
- "outputPath": ""
- },
- "enableEngineNative": false,
- "bundle": false,
- "useIsolateContext": true,
- "useCompilerModule": true,
- "userConfirmedUseCompilerModuleSwitch": false,
- "userConfirmedBundleSwitch": false,
- "packNpmManually": false,
- "packNpmRelationList": [],
- "minifyWXSS": true
- },
- "compileType": "miniprogram",
- "libVersion": "2.15.0",
- "appid": "wx9f6afd0fc5e708d4",
- "projectname": "eee",
- "cloudfunctionTemplateRoot": "",
- "watchOptions": {
- "ignore": []
- },
- "debugOptions": {
- "hidedInDevtools": []
- },
- "scripts": {},
- "condition": {
- "plugin": {
- "list": []
- },
- "game": {
- "list": []
- },
- "gamePlugin": {
- "list": []
- },
- "miniprogram": {
- "list": []
- }
- }
- }
复制代码
完工; 重新打开下微信开发者工具,就行了 ;
|
|