towxml icon indicating copy to clipboard operation
towxml copied to clipboard

在Taro 3中使用towxml

Open spiritree opened this issue 3 years ago • 17 comments

步骤

1. 构建towxml

参考3.0 构建Towxml

2. 同步构建完的towxml到项目中

image

修改 decode.json 转换为相对路径

{
  "component": true,
  "usingComponents": {
    "decode": "./decode",
    "audio-player": "./audio-player/audio-player",
    "latex": "./latex/latex",
    "table": "./table/table",
    "todogroup": "./todogroup/todogroup",
    "yuml": "./yuml/yuml",
    "img": "./img/img"
  }
}

在页面中配置文件 index.config.ts 引入

export default {
  usingComponents: {
    'to-wxml': '../../components/towxml/towxml',
  },
};

在页面中引用

import { useState, useEffect } from 'react';
import { View } from '@tarojs/components';
import towxml from 'src/components/towxml/index';

const html = `<p>awdawd</p>`;

export default function RichText() {
  const [res, setRes] = useState<any>(null);

  useEffect(() => {
    const result = towxml(html, 'html');
    setRes(result);
  }, []);

  return (
    <View>
      {/* @ts-ignore */}
      <to-wxml nodes={res} />
    </View>
  );
}

spiritree avatar Jun 28 '21 11:06 spiritree

使用之后,微信开发者工具会内存泄露,导致电脑卡死

justseeseesee avatar Jul 03 '21 14:07 justseeseesee

image 代码没有高亮显示是什么情况?

image image

3463135482 avatar Jul 08 '21 12:07 3463135482

步骤

1. 构建towxml

参考3.0 构建Towxml

2. 同步构建完的towxml到项目中

image

修改 decode.json 转换为相对路径

{
  "component": true,
  "usingComponents": {
    "decode": "./decode",
    "audio-player": "./audio-player/audio-player",
    "latex": "./latex/latex",
    "table": "./table/table",
    "todogroup": "./todogroup/todogroup",
    "yuml": "./yuml/yuml",
    "img": "./img/img"
  }
}

在页面中配置文件 index.config.ts 引入

export default {
  usingComponents: {
    'to-wxml': '../../components/towxml/towxml',
  },
};

在页面中引用

import { useState, useEffect } from 'react';
import { View } from '@tarojs/components';
import towxml from 'src/components/towxml/index';

const html = `<p>awdawd</p>`;

export default function RichText() {
  const [res, setRes] = useState<any>(null);

  useEffect(() => {
    const result = towxml(html, 'html');
    setRes(result);
  }, []);

  return (
    <View>
      {/* @ts-ignore */}
      <to-wxml nodes={res} />
    </View>
  );
}

按照示例写 。还是不可以

ghost avatar Feb 06 '22 07:02 ghost

步骤

1. 构建towxml

参考3.0 构建Towxml

2. 同步构建完的towxml到项目中

image 修改 decode.json 转换为相对路径

{
  "component": true,
  "usingComponents": {
    "decode": "./decode",
    "audio-player": "./audio-player/audio-player",
    "latex": "./latex/latex",
    "table": "./table/table",
    "todogroup": "./todogroup/todogroup",
    "yuml": "./yuml/yuml",
    "img": "./img/img"
  }
}

在页面中配置文件 index.config.ts 引入

export default {
  usingComponents: {
    'to-wxml': '../../components/towxml/towxml',
  },
};

在页面中引用

import { useState, useEffect } from 'react';
import { View } from '@tarojs/components';
import towxml from 'src/components/towxml/index';

const html = `<p>awdawd</p>`;

export default function RichText() {
  const [res, setRes] = useState<any>(null);

  useEffect(() => {
    const result = towxml(html, 'html');
    setRes(result);
  }, []);

  return (
    <View>
      {/* @ts-ignore */}
      <to-wxml nodes={res} />
    </View>
  );
}

按照示例写 。还是不可以

conifg/index.js 要 copy 下包吧

copy: {
    patterns: [
      // {
      //   from: "src/subPackages/prod/components/wemark",
      //   to: "dist/subPackages/prod/components/wemark"
      // }
      {
        from: "src/components/towxml",
        to: "src/components/towxml"
      }
    ],
    options: {}
  },

lynzz avatar Aug 08 '22 03:08 lynzz

我这出现的情况,是直接显示 markdown 源码了,这是为啥

image

lynzz avatar Aug 08 '22 03:08 lynzz

知道了,数据在服务端的没有 encode 导致的

lynzz avatar Aug 08 '22 08:08 lynzz

使用之后,微信开发者工具会内存泄露,导致电脑卡死

请问后来还有这个问题吗

CS-liujf avatar Feb 08 '23 12:02 CS-liujf

后来更新了开发者工具,使用修改后的Taro-parse来显示的markdown文件,好像没直接用towxml

justseeseesee avatar Feb 09 '23 01:02 justseeseesee

大家使用Taro一般用于公司业务还是个人业务?如果我提供Taro版本的支持,但会像征性收费是否合适?

sbfkcel avatar Feb 09 '23 01:02 sbfkcel

个人开发,就是好奇试了一下,个人觉得如果公司业务收费是合适的,但是愿意付费的应该不多吧。

justseeseesee avatar Feb 09 '23 01:02 justseeseesee

大家使用Taro一般用于公司业务还是个人业务?如果我提供Taro版本的支持,但会像征性收费是否合适?

有个人业务,但不排除公司,如果收费的话,请问是一次性的吗,从我个人角度来说不太希望定价超过30(请原谅我说话比较直接)

CS-liujf avatar Feb 09 '23 01:02 CS-liujf

开源不易,直接点挺好,目测这个定价你是自费,不找公司报销了啊。

justseeseesee avatar Feb 09 '23 01:02 justseeseesee

主要是我想做个东西“创业”,其实说创业也不准确,就想做个东西然后学校里推广一下

CS-liujf avatar Feb 09 '23 01:02 CS-liujf

我想的也不是要真的收多少钱,大概就是随意打赏的那种吧!5、10、15... 这种随意,土豪的就打赏多一点。这样开源本身也才有点存在感。

真的赚钱不太能指望开源。

sbfkcel avatar Feb 09 '23 02:02 sbfkcel

我想的也不是要真的收多少钱,大概就是随意打赏的那种吧!5、10、15... 这种随意,土豪的就打赏多一点。这样开源本身也才有点存在感。

真的赚钱不太能指望开源。

其实一杯咖啡钱或者一包烟钱,大伙都比较愿意给的

joket1999 avatar Jun 20 '23 08:06 joket1999

我想的也不是要真的收多少钱,大概就是随意打赏的那种吧!5、10、15... 这种随意,土豪的就打赏多一点。这样开源本身也才有点存在感。

真的赚钱不太能指望开源。

建议参考vue-admin这种项目,项目开源,技术支持收费。

huangwei9527 avatar Jul 12 '23 04:07 huangwei9527

步骤

1. 构建towxml

参考3.0 构建Towxml

2. 同步构建完的towxml到项目中

image 修改 decode.json 转换为相对路径

{
  "component": true,
  "usingComponents": {
    "decode": "./decode",
    "audio-player": "./audio-player/audio-player",
    "latex": "./latex/latex",
    "table": "./table/table",
    "todogroup": "./todogroup/todogroup",
    "yuml": "./yuml/yuml",
    "img": "./img/img"
  }
}

在页面中配置文件 index.config.ts 引入

export default {
  usingComponents: {
    'to-wxml': '../../components/towxml/towxml',
  },
};

在页面中引用

import { useState, useEffect } from 'react';
import { View } from '@tarojs/components';
import towxml from 'src/components/towxml/index';

const html = `<p>awdawd</p>`;

export default function RichText() {
  const [res, setRes] = useState<any>(null);

  useEffect(() => {
    const result = towxml(html, 'html');
    setRes(result);
  }, []);

  return (
    <View>
      {/* @ts-ignore */}
      <to-wxml nodes={res} />
    </View>
  );
}

按照示例写 。还是不可以

conifg/index.js 要 copy 下包吧

copy: {
    patterns: [
      // {
      //   from: "src/subPackages/prod/components/wemark",
      //   to: "dist/subPackages/prod/components/wemark"
      // }
      {
        from: "src/components/towxml",
        to: "src/components/towxml"
      }
    ],
    options: {}
  },

为什么我会出现这种报错呢?按照步骤来的 Component is not found in path "towxml/towxml" (using by "custom-tab-bar/index")(env: macOS,mp,1.06.2402040; lib: 3.4.4) Component is not found in path "towxml/towxml" (using by "comp")(env: macOS,mp,1.06.2402040; lib: 3.4.4) Component is not found in path "towxml/towxml" (using by "pages/index/index")(env: macOS,mp,1.06.2402040; lib: 3.4.4)

free-booter avatar May 30 '24 10:05 free-booter