使用内容脚本加载Bootstrap?

时间:2017-11-29 22:29:51

标签: twitter-bootstrap twitter-bootstrap-3 google-chrome-extension

将React Bootstrap合并到我的内容脚本中的正确方法是什么?



import React from 'react'
import ReactDOM from 'react-dom'
import App from './content/App'
import { Button } from 'react-bootstrap'

// Targeted UI component
const viewport = document.getElementById('viewport')

const app = document.createElement('div')
app.id = 'root'

// Can use appendChild instead of prepend
if (viewport) viewport.prepend(app)

ReactDOM.render(<Button bsStyle='primary'>Memes</Button>, document.getElementById('root'))
&#13;
&#13;
&#13;

上面没有功能或样式,没有地方放<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">

编辑:iFrame方法

&#13;
&#13;
var f = document.createElement('iframe')
f.src = chrome.extension.getURL('src/js/content/App.js')

console.log("TEST: " + f.src)

const viewport = document.getElementById('body')
viewport.prepend(f)
&#13;
&#13;
&#13;

&#13;
&#13;
...
"web_accessible_resources": [
    "src/js/content/App.js"
  ], ...
&#13;
&#13;
&#13;

返回带有错误的小灰色窗口&#39;它可能已被移动或删除&#39;

0 个答案:

没有答案