Html-react-parser: هل هو متوافق مع تنسيق htmlparser؟

تم إنشاؤها على ١٨ يناير ٢٠١٨  ·  3تعليقات  ·  مصدر: remarkablemark/html-react-parser

هل من الممكن أن نتصل بما يلي؟

// htmlparser format, not htmlparser2
const htmlparserDoc = [ { type: 'tag'
  , name: 'a'
  , attribs: { href: 'test.html' }
  , children: [ { data: 'hello world', type: 'text' } ]
  }
];

domToReact(htmlparserDoc, options);

يحتوي تنسيق htmlparser2 على مراجع دائرية ، مما يمنعنا من استدعاء JSON.stringify() عليه ، لذلك نود استخدام htmlparser إذا استطعنا.

التعليق الأكثر فائدة

أستطيع أن أؤكد أنه يعمل في الواقع!

انتهى بي الأمر باستخدام htmlparser2 ولكن تمت إزالة parent و next و prev يدويًا قبل الإرسال من الخادم إلى موكلي.

لأي شخص يتعثر في هذا ، هذا هو الكود الذي استخدمته لنزع تلك المراجع الدائرية:

JSON.stringify(obj,
    function(key, value) { 
        return key === 'parent' || key === 'next' || key === 'prev'
            ? undefined
            : value;
  });

ال 3 كومينتر

oliverodaa يجب أن يكون ممكناً:

$ node
> const domToReact = require('html-react-parser/lib/dom-to-react');
> const htmlparserDoc = [{ type: 'tag', name: 'a', attribs: { href: 'test.html' }, children: [{ data: 'hello world', type: 'text' }] }];
> domToReact(htmlparserDoc);
{ '$$typeof': Symbol(react.element),
  type: 'a',
  key: null,
  ref: null,
  props: { href: 'test.html', children: 'hello world' },
  _owner: null,
  _store: {} }

اسمحوا لي أن أعرف إذا كنت تواجه أي مشاكل ؛ خلاف ذلك ، الرجاء إغلاق المشكلة إذا كان يعمل.

شكرا للاستجابة السريعة! ما زلت في طور العمل عليها ، لكنني سأكون متأكدًا من إغلاق المشكلة عندما أؤكد أنها إما تعمل أو لا تعمل.

أستطيع أن أؤكد أنه يعمل في الواقع!

انتهى بي الأمر باستخدام htmlparser2 ولكن تمت إزالة parent و next و prev يدويًا قبل الإرسال من الخادم إلى موكلي.

لأي شخص يتعثر في هذا ، هذا هو الكود الذي استخدمته لنزع تلك المراجع الدائرية:

JSON.stringify(obj,
    function(key, value) { 
        return key === 'parent' || key === 'next' || key === 'prev'
            ? undefined
            : value;
  });
هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات

القضايا ذات الصلة

rscott78 picture rscott78  ·  11تعليقات

linkelvin11 picture linkelvin11  ·  4تعليقات

lhtdesignde picture lhtdesignde  ·  9تعليقات

shiglet picture shiglet  ·  6تعليقات

christianfredh picture christianfredh  ·  5تعليقات