webpack使用原生js和react分别搭建项目-创新互联
- 原生js:
a. head.jsx:function head(){ var head = document.createElement('div') head.setAttribute('class','head') head.innerHTML = "head" return head } module.exports = head
b. table.jsx:
成都创新互联公司成都企业网站建设服务,提供成都网站设计、成都网站建设网站开发,网站定制,建网站,网站搭建,网站设计,响应式网站建设,网页设计师打造企业风格网站,提供周到的售前咨询和贴心的售后服务。欢迎咨询做网站需要多少钱:13518219792function table(){ var table = document.createElement('table') table.setAttribute('class','table') var thead = document.createElement('thead') var tbody = document.createElement('tbody') var tdh = document.createElement('td') var tdb = document.createElement('td') var tnh = document.createTextNode('title') var tnb = document.createTextNode('body') tdh.appendChild(tnh) tdb.appendChild(tnb) thead.appendChild(tdh) tbody.appendChild(tdb) table.appendChild(thead) table.appendChild(tbody) return table } module.exports = table
c. foot.jsx:
function foot(){ var foot = document.createElement('div') foot.setAttribute('class','foot') foot.innerHTML = "foot" return foot } module.exports = foot
d. test.less:
.color(@color;@background){ color:@color; background:@background; } .table(){ border-collapse:collapse; border:1px solid black; padding:1vh 1vw; } .head{ .color(red,yellow); } .table{ .table(); } .foot{ .color(white,black); }
e. index.js:
var head = require('./static/jsx/head.jsx') var table = require('./static/jsx/table.jsx') var foot = require('./static/jsx/foot.jsx') require('./static/less/test.less') document.body.appendChild(head()) document.body.appendChild(table()) document.body.appendChild(foot())
f. index.html:
hello g. 效果:
- react:
a. head.jsx:var React = require('react') var CreateReactClass = require('create-react-class') var head = CreateReactClass({ render:function(){ return(
head) } }) module.exports = headb. table.jsx:
var React = require('react') var CreateReactClass = require('create-react-class') var table = CreateReactClass({ render:function(){ return(
head body c. foot.jsx:
var React = require('react') var CreateReactClass = require('create-react-class') var foot = CreateReactClass({ render:function(){ return(
foot) } }) module.exports = footd. test.less:
.color(@color;@background){ color:@color; background:@background; } .table(){ border-collapse:collapse; border:1px solid black; padding:1vh 1vw; } .head{ .color(red,yellow); } .table{ .table(); } .foot{ .color(white,black); }
e. index.js:
var React = require('react') var ReactDom = require('react-dom') var CreateReactClass = require('create-react-class') var Head = require('./static/jsx/head.jsx') var Table = require('./static/jsx/table.jsx') var Foot = require('./static/jsx/foot.jsx') require('./static/less/test.less') var App = CreateReactClass({ render:function(){ return(
f. index.html:
hello
g. 效果:
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:webpack使用原生js和react分别搭建项目-创新互联
网站网址:http://cdiso.cn/article/ioogd.html