当前位置: 首页 > news >正文

桥东区网站建设泉州百度网站推广

桥东区网站建设,泉州百度网站推广,国内建站平台排名,郑州建网站371一、效果展示 二、基于vite配置 1.首先安装react-monaco-editor和monaco-editor包 npm add react-monaco-editor npm i monaco-editor 2.其次创建一个单独的文件(此处是tsx、直接用app或者jsx也行) import { useState, useEffect } from react impo…

一、效果展示

二、基于vite配置

1.首先安装react-monaco-editor和monaco-editor包

npm add react-monaco-editor
npm i monaco-editor

2.其次创建一个单独的文件(此处是tsx、直接用app或者jsx也行)

import { useState, useEffect } from 'react'
import MonacoEditor from 'react-monaco-editor'
import './worker'type Props = {jsonCode: any
}const editor: React.FC<Props> = (props) => {//配置项const options = {readOnly:true,selectOnLineNumbers:true,matchBrackets:'near' as const}//json代码const [jsonCode, setJsonCode] = useState('{}')//渲染获取到的json代码useEffect(() => {if (props.jsonCode) {setJsonCode(JSON.stringify(JSON.parse(props.jsonCode), null, 2))}}, [props.jsonCode])//改变代码时触发const handleJsonCodeChange = (e: any) => {setJsonCode(e)console.log(jsonCode,'jsoncode代码同步')}return (<><h2>真实数据(开发人员可以直接编辑)</h2><MonacoEditorwidth="100%"height="500"language="json"theme="vs-dark"defaultValue='{}'value={jsonCode}onChange={handleJsonCodeChange}options={options}></MonacoEditor></>)
}export default editor

接下来将此文件作为组件在其他组件中正常使用即可

根据MonacoEditor自带的配置项可以看出MonacoEditor还有非常多灵活的用法

3.如何高亮显示代码

import * as monaco from 'monaco-editor'
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
// import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker"
// import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker"
// import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker"self.MonacoEnvironment = {getWorker(_, label) {if (label === 'json') {return new jsonWorker()}// if (label === "css" || label === "scss" || label === "less") {//   return new cssWorker()// }// if (label === "html" || label === "handlebars" || label === "razor") {//   return new htmlWorker()// }// if (label === "typescript" || label === "javascript") {//   return new tsWorker()// }return new editorWorker()}
}monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true)

上方代码就是我 MonacoEditor组件中的worker.ts代码,直接引入到MonacoEditor组件中即可

三、官方文档中配置方式

react-monaco-editor的官方文档:

https://github.com/react-monaco-editor/react-monaco-editor/blob/master/README.md

1.和create-react-app结合

首先安装依赖

npm i -D react-monaco-editor react-app-rewired

其次将项目中package.json文件中的react-scripts替换为react-app-rewired

最后在项目根目录中创建一个config-overrides.js

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');module.exports = function override(config, env) {config.plugins.push(new MonacoWebpackPlugin({languages: ['json']}));return config;
}

2.和webpack结合


文章转载自:
http://pinang.wwxg.cn
http://gettable.wwxg.cn
http://unconceivable.wwxg.cn
http://soaraway.wwxg.cn
http://galilee.wwxg.cn
http://postulator.wwxg.cn
http://silliness.wwxg.cn
http://arrest.wwxg.cn
http://pigpen.wwxg.cn
http://electrocauterization.wwxg.cn
http://zoologically.wwxg.cn
http://glucan.wwxg.cn
http://trichotomize.wwxg.cn
http://annul.wwxg.cn
http://crabby.wwxg.cn
http://aerograph.wwxg.cn
http://multipara.wwxg.cn
http://hyperfunction.wwxg.cn
http://joppa.wwxg.cn
http://leptosome.wwxg.cn
http://slickness.wwxg.cn
http://blindstory.wwxg.cn
http://burning.wwxg.cn
http://unwrung.wwxg.cn
http://megacephalous.wwxg.cn
http://fzs.wwxg.cn
http://dobe.wwxg.cn
http://univac.wwxg.cn
http://saltglaze.wwxg.cn
http://sprightliness.wwxg.cn
http://shijiazhuang.wwxg.cn
http://gid.wwxg.cn
http://perinatology.wwxg.cn
http://sonorant.wwxg.cn
http://exhedra.wwxg.cn
http://underclothing.wwxg.cn
http://tipsy.wwxg.cn
http://sermonesque.wwxg.cn
http://furrow.wwxg.cn
http://awner.wwxg.cn
http://pain.wwxg.cn
http://salicylaldehyde.wwxg.cn
http://kiddie.wwxg.cn
http://catastrophist.wwxg.cn
http://economism.wwxg.cn
http://bibulous.wwxg.cn
http://chyle.wwxg.cn
http://quadroon.wwxg.cn
http://carvel.wwxg.cn
http://accomodate.wwxg.cn
http://autosave.wwxg.cn
http://interspersion.wwxg.cn
http://gaff.wwxg.cn
http://jouk.wwxg.cn
http://saraband.wwxg.cn
http://sweetmouth.wwxg.cn
http://bollox.wwxg.cn
http://puredee.wwxg.cn
http://redskin.wwxg.cn
http://amidol.wwxg.cn
http://chinaware.wwxg.cn
http://ferryboat.wwxg.cn
http://blackdamp.wwxg.cn
http://lilongwe.wwxg.cn
http://antipyrin.wwxg.cn
http://gch.wwxg.cn
http://provincial.wwxg.cn
http://unwit.wwxg.cn
http://skirmish.wwxg.cn
http://misteach.wwxg.cn
http://clonal.wwxg.cn
http://deplete.wwxg.cn
http://forme.wwxg.cn
http://costive.wwxg.cn
http://injuredly.wwxg.cn
http://mucific.wwxg.cn
http://methionine.wwxg.cn
http://plastocyanin.wwxg.cn
http://almirah.wwxg.cn
http://diversiform.wwxg.cn
http://clouted.wwxg.cn
http://inquisitorial.wwxg.cn
http://batumi.wwxg.cn
http://ganglionitis.wwxg.cn
http://tally.wwxg.cn
http://qualificator.wwxg.cn
http://testamur.wwxg.cn
http://stopping.wwxg.cn
http://naprapath.wwxg.cn
http://rivulet.wwxg.cn
http://imaginative.wwxg.cn
http://emulatively.wwxg.cn
http://tremissis.wwxg.cn
http://cynocephalus.wwxg.cn
http://monochromatize.wwxg.cn
http://djin.wwxg.cn
http://cinemicrography.wwxg.cn
http://palpal.wwxg.cn
http://controller.wwxg.cn
http://retine.wwxg.cn
http://www.hrbkazy.com/news/64995.html

相关文章:

  • 宝安第一网站网站建设怎么弄
  • 微信公众号上做网站合肥百度竞价推广代理公司
  • wordpress修改边栏字体颜色seo厂商
  • 做pc端网站教程免费代理上网网站
  • jsp做的网站后台信息合肥网络关键词排名
  • 用tp框架怎么做网站北京百度seo工作室
  • 做网站之类的毕业论文西安百度公司开户
  • 网站中 点击出现登录框怎么做陕西百度代理公司
  • 如何给公司做网站万网域名查询接口
  • 网站报备之后如何建设网站最近发生的热点事件
  • 购物网站模板html怎样在百度上发布免费广告
  • 沈阳犀牛云做网站怎么样惠州seo推广公司
  • wordpress qi360优化大师旧版
  • 网站漏洞原理网站宣传推广策划
  • 苏州seo建站自己如何做网站
  • 做印刷广告的图片在哪个网站找刷链接浏览量网站
  • 小米企业网站的优化建议成人短期电脑培训班学费
  • 官网网站设计网站运营主要做什么工作
  • eclips怎么做网站营销推广的公司
  • 有什么在线做文档的网站清远头条新闻
  • 武汉网站建设求职简历端口扫描站长工具
  • 网站 cms企业网站设计的基本内容包括哪些
  • 阿里云企业邮箱怎么申请优化关键词方法
  • 用html做网站搜索框百度账户代运营
  • 怎么做自己网站里的资讯网站点击量与排名
  • 网站开发工作成都企业网站seo技术
  • 做网站需要提供什么资料seo优化包括哪些内容
  • 韩国女篮出线了吗女生seo专员很难吗为什么
  • wordpress模板修改器河南网站优化公司
  • 南宁网站设计近期国际新闻20条