是否可以在React内部使用Polymer? [英] Is it possible to use Polymer inside of React?

查看:69
本文介绍了是否可以在React内部使用Polymer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用React,并希望在React内使用Polymer标签. React无法识别Polymer标签,因为React仅处理基本的DOM标签.有没有办法将Polymer标签添加到React DOM库?

I have been using React and look to use Polymer tags inside of React. React does not recognize Polymer tags as React only handles basic DOM tags. Is there a way to add the Polymer tags to React DOM library?

推荐答案

是的,有可能.

  1. 创建一个聚合物元素.

  1. Create a polymer element.

<link rel="import" href="../../bower_components/polymer/polymer.html">

Polymer({
    is: 'calender-element',
    ready: function(){
        this.textContent = "I am a calender";
    }
});

  • 通过将聚合物组件导入html页面,使它成为html标签.例如.将其导入您的React应用程序的index.html中.

  • Make the polymer component a html tag by importing it in a html page. E.g. import it in the index.html of your react application.

    <link rel="import" href="./src/polymer-components/calender-element.html">
    

  • 在jsx文件中使用该元素.

  • Use that element in the jsx file.

    'use strict';
    
    import React from 'react';
    
    class MyComponent extends React.Component{
        render(){
            return (
                <calender-element></calender-element>
            );
        }
    }
    
    export default MyComponent;
    

  • 这篇关于是否可以在React内部使用Polymer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆