ab2be24ca841a22980ee85469eb53f8e9e4b3a189c34fc180d8cdfc88d7f76a5541d51224018246f4bf3ca490d1242aede5418782fc4f74065f8cef8f52db0 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. <template>
  2. <div class="wrapper">
  3. <div class="model" v-show="model">
  4. <div class="model-show" @click="model = false">
  5. <img :src="modelSrc" alt="" @click="model = false">
  6. </div>
  7. </div>
  8. <div class="content">
  9. <h1><a class="title" href="https://github.com/xyxiao001/vue-cropper" target="_blank">vue-cropper</a></h1>
  10. <iframe src="https://ghbtns.com/github-btn.html?user=xyxiao001&repo=vue-cropper&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
  11. <div class="show-info">
  12. <h2>install</h2>
  13. <codes>
  14. <div slot="body">{{ code0 }}</div>
  15. </codes>
  16. </div>
  17. <div class="show-info">
  18. <h2>example1 基本例子 无限制</h2>
  19. <div class="test test1">
  20. <vueCropper
  21. ref="cropper"
  22. :img="option.img"
  23. :outputSize="option.size"
  24. :outputType="option.outputType"
  25. :info="true"
  26. :full="option.full"
  27. :canMove="option.canMove"
  28. :canMoveBox="option.canMoveBox"
  29. :fixedBox="option.fixedBox"
  30. :original="option.original"
  31. :autoCrop="option.autoCrop"
  32. :autoCropWidth="option.autoCropWidth"
  33. :autoCropHeight="option.autoCropHeight"
  34. :centerBox="option.centerBox"
  35. :high="option.high"
  36. :infoTrue="option.infoTrue"
  37. :maxImgSize="option.maxImgSize"
  38. @realTime="realTime"
  39. @imgLoad="imgLoad"
  40. @cropMoving="cropMoving"
  41. :enlarge="option.enlarge"
  42. :mode="option.mode"
  43. :limitMinSize="option.limitMinSize"
  44. ></vueCropper>
  45. </div>
  46. <div class="test-button">
  47. <button @click="changeImg" class="btn">changeImg</button>
  48. <label class="btn" for="uploads">upload</label>
  49. <input type="file" id="uploads" style="position:absolute; clip:rect(0 0 0 0);" accept="image/png, image/jpeg, image/gif, image/jpg" @change="uploadImg($event, 1)" ref="uploadImg">
  50. <button @click="startCrop" v-if="!crap" class="btn">start</button>
  51. <button @click="stopCrop" v-else class="btn">stop</button>
  52. <button @click="clearCrop" class="btn">clear</button>
  53. <button @click="refreshCrop" class="btn">refresh</button>
  54. <button @click="changeScale(1)" class="btn">+</button>
  55. <button @click="changeScale(-1)" class="btn">-</button>
  56. <button @click="rotateLeft" class="btn">rotateLeft</button>
  57. <button @click="rotateRight" class="btn">rotateRight</button>
  58. <button @click="finish('base64')" class="btn">preview(base64)</button>
  59. <button @click="finish('blob')" class="btn">preview(blob)</button>
  60. <button @click="() => option.img = ''" class="btn">清除图片</button>
  61. <a @click="down('base64')" class="btn">download(base64)</a>
  62. <a @click="down('blob')" class="btn">download(blob)</a>
  63. <a :href="downImg" download="demo.png" ref="downloadDom"></a>
  64. </div>
  65. <div class="pre">
  66. <!-- <section class="pre-item">
  67. <p>固定大小 固定宽度100px</p>
  68. <section v-html="previews.html"></section>
  69. </section> -->
  70. <section class="pre-item">
  71. <p>截图框大小</p>
  72. <div class="show-preview" :style="{'width': previews.w + 'px', 'height': previews.h + 'px', 'overflow': 'hidden',
  73. 'margin': '5px'}">
  74. <div :style="previews.div">
  75. <img :src="previews.url" :style="previews.img">
  76. </div>
  77. </div>
  78. </section>
  79. <section class="pre-item">
  80. <p>中等大小</p>
  81. <div :style="previewStyle1">
  82. <div :style="previews.div">
  83. <img :src="previews.url" :style="previews.img">
  84. </div>
  85. </div>
  86. </section>
  87. <section class="pre-item">
  88. <p>迷你大小</p>
  89. <div :style="previewStyle2">
  90. <div :style="previews.div">
  91. <img :src="previews.url" :style="previews.img">
  92. </div>
  93. </div>
  94. </section>
  95. <section class="pre-item" title="zoom: (100 / previews.w)">
  96. <p>固定为100宽度</p>
  97. <div :style="previewStyle3">
  98. <div :style="previews.div">
  99. <img :src="previews.url" :style="previews.img">
  100. </div>
  101. </div>
  102. </section>
  103. <section class="pre-item" title="zoom: (100 / previews.h)">
  104. <p>固定为100高度</p>
  105. <div :style="previewStyle4">
  106. <div :style="previews.div">
  107. <img :src="previews.url" :style="previews.img">
  108. </div>
  109. </div>
  110. </section>
  111. </div>
  112. <div style="display:block; width: 100%;">
  113. <label class="c-item">
  114. <span>图片默认渲染方式</span>
  115. <select v-model="option.mode">
  116. <option value="contain">contain</option>
  117. <option value="cover">cover</option>
  118. <option value="400px auto">400px auto</option>
  119. <option value="auto 400px">auto 400px</option>
  120. <option value="50%">50%</option>
  121. <option value="auto 50%">auto 50%</option>
  122. </select>
  123. <section>
  124. 类似css background属性设置 设置不符合规范不生效, 参照文档说明
  125. </section>
  126. </label>
  127. <!-- <label class="c-item">
  128. <span>截图框最小限制 </span>
  129. <input type="text" v-model="option.limitMinSize">
  130. </label> -->
  131. <label class="c-item">
  132. <span>上传时图片最大大小(默认会压缩尺寸到这个大小)</span>
  133. <input type="nubmer" v-model="option.maxImgSize">
  134. </label>
  135. <label class="c-item">
  136. <span>上传图片是否显示原始宽高 (针对大图 可以铺满)</span>
  137. <input type="checkbox" v-model="option.original">
  138. <span>original: {{ option.original}}</span>
  139. </label>
  140. <label class="c-item">
  141. <span>是否根据dpr生成适合屏幕的高清图片</span>
  142. <input type="checkbox" v-model="option.high">
  143. <span>high: {{ option.high}}</span>
  144. </label>
  145. <label class="c-item">
  146. <span>是否输出原图比例的截图</span>
  147. <input type="checkbox" v-model="option.full">
  148. <span>full: {{ option.full}}</span>
  149. </label>
  150. <label class="c-item">
  151. <span>截图信息展示是否是真实的输出宽高</span>
  152. <input type="checkbox" v-model="option.infoTrue">
  153. <span>infoTrue: {{ option.infoTrue}}</span>
  154. </label>
  155. <label class="c-item">
  156. <span>能否拖动图片</span>
  157. <input type="checkbox" v-model="option.canMove">
  158. <span>canMove: {{ option.canMove}}</span>
  159. </label>
  160. <label class="c-item">
  161. <span>能否拖动截图框</span>
  162. <input type="checkbox" v-model="option.canMoveBox">
  163. <span>canMoveBox: {{ option.canMoveBox}}</span>
  164. </label>
  165. <label class="c-item">
  166. <span>截图框固定大小</span>
  167. <input type="checkbox" v-model="option.fixedBox">
  168. <span>fixedBox: {{ option.fixedBox}}</span>
  169. </label>
  170. <label class="c-item">
  171. <span>是否自动生成截图框</span>
  172. <input type="checkbox" v-model="option.autoCrop">
  173. <span>autoCrop: {{ option.autoCrop}}</span>
  174. </label>
  175. <label class="c-item">
  176. <span>自动生成截图框的宽高</span>
  177. <span>宽度: </span><input type="number" v-model="option.autoCropWidth">
  178. <span>高度: </span><input type="number" v-model="option.autoCropHeight">
  179. </label>
  180. <label class="c-item">
  181. <span>截图框是否限制在图片里(只有在自动生成截图框时才能生效)</span>
  182. <input type="checkbox" v-model="option.centerBox">
  183. <span>centerBox: {{ option.centerBox}}</span>
  184. </label>
  185. <label class="c-item">
  186. <span>是否按照截图框比例输出 默认为1 </span>
  187. <input type="number" v-model="option.enlarge">
  188. </label>
  189. <p>输出图片格式</p>
  190. <label class="c-item">
  191. <label>jpg <input type="radio" name="type" value="jpeg" v-model="option.outputType"></label>
  192. <label>png <input type="radio" name="type" value="png" v-model="option.outputType"></label>
  193. <label>webp <input type="radio" name="type" value="webp" v-model="option.outputType"></label>
  194. </label>
  195. </div>
  196. <codes>
  197. <div slot="body">{{ code1 }}</div>
  198. </codes>
  199. </div>
  200. </div>
  201. </div>
  202. </template>
  203. <script>
  204. import VueCropper from "./vue-cropper/vue-cropper";
  205. // import { VueCropper } from '../test'
  206. import codes from "./code";
  207. export default {
  208. data: function() {
  209. return {
  210. model: false,
  211. modelSrc: "",
  212. crap: false,
  213. previews: {},
  214. lists: [
  215. // {
  216. // img: 'https://fengyuanchen.github.io/cropper/images/picture.jpg'
  217. // },
  218. {
  219. img: "https://avatars2.githubusercontent.com/u/15681693?s=460&v=4"
  220. },
  221. {
  222. img: "http://cdn.xyxiao.cn/Landscape_1.jpg"
  223. },
  224. {
  225. img: "http://cdn.xyxiao.cn/Landscape_2.jpg"
  226. },
  227. {
  228. img: "http://cdn.xyxiao.cn/Landscape_3.jpg"
  229. },
  230. {
  231. img: "http://cdn.xyxiao.cn/Landscape_4.jpg"
  232. },
  233. {
  234. img: "http://cdn.xyxiao.cn/Portrait_1.jpg"
  235. },
  236. {
  237. img: "http://cdn.xyxiao.cn/Portrait_2.jpg"
  238. }
  239. ],
  240. option: {
  241. img: "",
  242. size: 1,
  243. full: false,
  244. outputType: "png",
  245. canMove: true,
  246. fixedBox: false,
  247. original: false,
  248. canMoveBox: true,
  249. autoCrop: true,
  250. // 只有自动截图开启 宽度高度才生效
  251. autoCropWidth: 200,
  252. autoCropHeight: 150,
  253. centerBox: false,
  254. high: false,
  255. cropData: {},
  256. enlarge: 1,
  257. mode: 'contain',
  258. maxImgSize: 3000,
  259. limitMinSize: [100, 120]
  260. },
  261. example2: {
  262. img: "http://cdn.xyxiao.cn/Landscape_2.jpg",
  263. info: true,
  264. size: 1,
  265. outputType: "jpeg",
  266. canScale: true,
  267. autoCrop: true,
  268. // 只有自动截图开启 宽度高度才生效
  269. autoCropWidth: 300,
  270. autoCropHeight: 250,
  271. fixed: true,
  272. // 真实的输出宽高
  273. infoTrue: true,
  274. fixedNumber: [4, 3]
  275. },
  276. example3: {
  277. img: "http://cdn.xyxiao.cn/Landscape_1.jpg",
  278. autoCrop: true,
  279. autoCropWidth: 200,
  280. autoCropHeight: 200,
  281. fixedBox: true
  282. },
  283. downImg: "#",
  284. previewStyle1: {},
  285. previewStyle2: {},
  286. previewStyle3: {},
  287. previewStyle4: {},
  288. code0: '',
  289. code1: '',
  290. code2: '',
  291. code3: '',
  292. preview3: '',
  293. };
  294. },
  295. methods: {
  296. changeImg() {
  297. this.option.img = this.lists[~~(Math.random() * this.lists.length)].img;
  298. },
  299. startCrop() {
  300. // start
  301. this.crap = true;
  302. this.$refs.cropper.startCrop();
  303. },
  304. stopCrop() {
  305. // stop
  306. this.crap = false;
  307. this.$refs.cropper.stopCrop();
  308. },
  309. clearCrop() {
  310. // clear
  311. this.$refs.cropper.clearCrop();
  312. },
  313. refreshCrop() {
  314. // clear
  315. this.$refs.cropper.refresh();
  316. },
  317. changeScale(num) {
  318. num = num || 1;
  319. this.$refs.cropper.changeScale(num);
  320. },
  321. rotateLeft() {
  322. this.$refs.cropper.rotateLeft();
  323. },
  324. rotateRight() {
  325. this.$refs.cropper.rotateRight();
  326. },
  327. finish(type) {
  328. // 输出
  329. // var test = window.open('about:blank')
  330. // test.document.body.innerHTML = '图片生成中..'
  331. if (type === "blob") {
  332. this.$refs.cropper.getCropBlob(data => {
  333. var img = window.URL.createObjectURL(data);
  334. this.model = true;
  335. this.modelSrc = img;
  336. });
  337. } else {
  338. this.$refs.cropper.getCropData(data => {
  339. this.model = true;
  340. this.modelSrc = data;
  341. });
  342. }
  343. },
  344. // 实时预览函数
  345. realTime(data) {
  346. var previews = data;
  347. var h = 0.5;
  348. var w = 0.2;
  349. this.previewStyle1 = {
  350. width: previews.w + "px",
  351. height: previews.h + "px",
  352. overflow: "hidden",
  353. margin: "0",
  354. zoom: h
  355. };
  356. this.previewStyle2 = {
  357. width: previews.w + "px",
  358. height: previews.h + "px",
  359. overflow: "hidden",
  360. margin: "0",
  361. zoom: w
  362. };
  363. this.previewStyle3 = {
  364. width: previews.w + "px",
  365. height: previews.h + "px",
  366. overflow: "hidden",
  367. margin: "0",
  368. zoom: (100 / previews.w)
  369. };
  370. this.previewStyle4 = {
  371. width: previews.w + "px",
  372. height: previews.h + "px",
  373. overflow: "hidden",
  374. margin: "0",
  375. zoom: (100 / previews.h)
  376. };
  377. this.previews = data;
  378. },
  379. finish2(type) {
  380. this.$refs.cropper2.getCropData(data => {
  381. this.model = true;
  382. this.modelSrc = data;
  383. });
  384. },
  385. finish3(type) {
  386. this.$refs.cropper3.getCropData(data => {
  387. this.model = true;
  388. this.modelSrc = data;
  389. });
  390. },
  391. down(type) {
  392. // event.preventDefault()
  393. // 输出
  394. if (type === "blob") {
  395. this.$refs.cropper.getCropBlob(data => {
  396. this.downImg = window.URL.createObjectURL(data);
  397. if (window.navigator.msSaveBlob) {
  398. var blobObject = new Blob([data]);
  399. window.navigator.msSaveBlob(blobObject, "demo.png");
  400. } else {
  401. this.$nextTick(() => {
  402. this.$refs.downloadDom.click();
  403. });
  404. }
  405. });
  406. } else {
  407. this.$refs.cropper.getCropData(data => {
  408. this.downImg = data;
  409. if (window.navigator.msSaveBlob) {
  410. var blobObject = new Blob([data]);
  411. window.navigator.msSaveBlob(blobObject, "demo.png");
  412. } else {
  413. this.$nextTick(() => {
  414. this.$refs.downloadDom.click();
  415. });
  416. }
  417. });
  418. }
  419. },
  420. uploadImg(e, num) {
  421. //上传图片
  422. // this.option.img
  423. var file = e.target.files[0];
  424. if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
  425. alert("图片类型必须是.gif,jpeg,jpg,png,bmp中的一种");
  426. return false;
  427. }
  428. var reader = new FileReader();
  429. reader.onload = e => {
  430. let data;
  431. if (typeof e.target.result === "object") {
  432. // 把Array Buffer转化为blob 如果是base64不需要
  433. data = window.URL.createObjectURL(new Blob([e.target.result]));
  434. } else {
  435. data = e.target.result;
  436. }
  437. if (num === 1) {
  438. this.option.img = data;
  439. } else if (num === 2) {
  440. this.example2.img = data;
  441. }
  442. this.$refs.uploadImg.value = ''
  443. };
  444. // 转化为base64
  445. // reader.readAsDataURL(file)
  446. // 转化为blob
  447. reader.readAsArrayBuffer(file);
  448. },
  449. imgLoad(msg) {
  450. console.log(msg);
  451. },
  452. cropMoving(data) {
  453. this.option.cropData = data;
  454. }
  455. },
  456. components: {
  457. VueCropper,
  458. codes
  459. },
  460. mounted() {
  461. this.changeImg();
  462. // hljs.configure({useBR: true})
  463. var list = [].slice.call(document.querySelectorAll("pre code"));
  464. list.forEach((val, index) => {
  465. hljs.highlightBlock(val);
  466. });
  467. // console.log(this.$refs.cropper)
  468. this.code0 = `
  469. npm install vue-cropper
  470. // 组件内使用
  471. import { VueCropper } from 'vue-cropper'
  472. components: {
  473. VueCropper,
  474. },
  475. // main.js里面使用
  476. import VueCropper from 'vue-cropper'
  477. Vue.use(VueCropper)
  478. // cdn方式使用
  479. <script src="vuecropper.js">\<\/script>
  480. Vue.use(window['vue-cropper'])
  481. <vueCropper
  482. ref="cropper"
  483. :img="option.img"
  484. :outputSize="option.size"
  485. :outputType="option.outputType"
  486. ></vueCropper>
  487. `
  488. this.code1 = `
  489. <div class="show-info">
  490. <h2>example1 基本例子 无限制</h2>
  491. <div class="test test1">
  492. <vueCropper
  493. ref="cropper"
  494. :img="option.img"
  495. :outputSize="option.size"
  496. :outputType="option.outputType"
  497. :info="true"
  498. :full="option.full"
  499. :canMove="option.canMove"
  500. :canMoveBox="option.canMoveBox"
  501. :fixedBox="option.fixedBox"
  502. :original="option.original"
  503. :autoCrop="option.autoCrop"
  504. :autoCropWidth="option.autoCropWidth"
  505. :autoCropHeight="option.autoCropHeight"
  506. :centerBox="option.centerBox"
  507. :high="option.high"
  508. :infoTrue="option.infoTrue"
  509. @realTime="realTime"
  510. @imgLoad="imgLoad"
  511. @cropMoving="cropMoving"
  512. :enlarge="option.enlarge"
  513. ></vueCropper>
  514. </div>
  515. <div class="test-button">
  516. <button @click="changeImg" class="btn">changeImg</button>
  517. <label class="btn" for="uploads">upload</label>
  518. <input type="file" id="uploads" style="position:absolute; clip:rect(0 0 0 0);" accept="image/png, image/jpeg, image/gif, image/jpg" @change="uploadImg($event, 1)">
  519. <button @click="startCrop" v-if="!crap" class="btn">start</button>
  520. <button @click="stopCrop" v-else class="btn">stop</button>
  521. <button @click="clearCrop" class="btn">clear</button>
  522. <button @click="refreshCrop" class="btn">refresh</button>
  523. <button @click="changeScale(1)" class="btn">+</button>
  524. <button @click="changeScale(-1)" class="btn">-</button>
  525. <button @click="rotateLeft" class="btn">rotateLeft</button>
  526. <button @click="rotateRight" class="btn">rotateRight</button>
  527. <button @click="finish('base64')" class="btn">preview(base64)</button>
  528. <button @click="finish('blob')" class="btn">preview(blob)</button>
  529. <a @click="down('base64')" class="btn">download(base64)</a>
  530. <a @click="down('blob')" class="btn">download(blob)</a>
  531. <a :href="downImg" download="demo.png" ref="downloadDom"></a>
  532. </div>
  533. <p>截图框大小</p>
  534. <div class="show-preview" :style="{'width': previews.w + 'px', 'height': previews.h + 'px', 'overflow': 'hidden',
  535. 'margin': '5px'}">
  536. <div :style="previews.div">
  537. <img :src="previews.url" :style="previews.img">
  538. </div>
  539. </div>
  540. <p>中等大小</p>
  541. <div :style="previewStyle1">
  542. <div :style="previews.div">
  543. <img :src="previews.url" :style="previews.img">
  544. </div>
  545. </div>
  546. <p>迷你大小</p>
  547. <div :style="previewStyle2">
  548. <div :style="previews.div">
  549. <img :src="previews.url" :style="previews.img">
  550. </div>
  551. </div>
  552. <div style="display:block; width: 100%;">
  553. <label class="c-item">
  554. <span>上传图片是否显示原始宽高 (针对大图 可以铺满)</span>
  555. <input type="checkbox" v-model="option.original">
  556. <span>original: {{ option.original}}</span>
  557. </label>
  558. <label class="c-item">
  559. <span>是否根据dpr生成适合屏幕的高清图片</span>
  560. <input type="checkbox" v-model="option.high">
  561. <span>high: {{ option.high}}</span>
  562. </label>
  563. <label class="c-item">
  564. <span>是否输出原图比例的截图</span>
  565. <input type="checkbox" v-model="option.full">
  566. <span>full: {{ option.full}}</span>
  567. </label>
  568. <label class="c-item">
  569. <span>截图信息展示是否是真实的输出宽高</span>
  570. <input type="checkbox" v-model="option.infoTrue">
  571. <span>infoTrue: {{ option.infoTrue}}</span>
  572. </label>
  573. <label class="c-item">
  574. <span>能否拖动图片</span>
  575. <input type="checkbox" v-model="option.canMove">
  576. <span>canMove: {{ option.canMove}}</span>
  577. </label>
  578. <label class="c-item">
  579. <span>能否拖动截图框</span>
  580. <input type="checkbox" v-model="option.canMoveBox">
  581. <span>canMoveBox: {{ option.canMoveBox}}</span>
  582. </label>
  583. <label class="c-item">
  584. <span>截图框固定大小</span>
  585. <input type="checkbox" v-model="option.fixedBox">
  586. <span>fixedBox: {{ option.fixedBox}}</span>
  587. </label>
  588. <label class="c-item">
  589. <span>是否自动生成截图框</span>
  590. <input type="checkbox" v-model="option.autoCrop">
  591. <span>autoCrop: {{ option.autoCrop}}</span>
  592. </label>
  593. <label class="c-item">
  594. <span>截图框是否限制在图片里(只有在自动生成截图框时才能生效)</span>
  595. <input type="checkbox" v-model="option.centerBox">
  596. <span>centerBox: {{ option.centerBox}}</span>
  597. </label>
  598. <label class="c-item">
  599. <span>是否按照截图框比例输出 默认为1 </span>
  600. <input type="number" v-model="option.enlarge">
  601. </label>
  602. <p>输出图片格式</p>
  603. <label class="c-item">
  604. <label>jpg <input type="radio" name="type" value="jpeg" v-model="option.outputType"></label>
  605. <label>png <input type="radio" name="type" value="png" v-model="option.outputType"></label>
  606. <label>webp <input type="radio" name="type" value="webp" v-model="option.outputType"></label>
  607. </label>
  608. </div>
  609. <codes>
  610. <div slot="body">{{ code1 }}</div>
  611. </codes>
  612. </div>
  613. `
  614. }
  615. };
  616. </script>
  617. <style>
  618. * {
  619. margin: 0;
  620. padding: 0;
  621. }
  622. .content {
  623. margin: auto;
  624. max-width: 1200px;
  625. margin-bottom: 100px;
  626. }
  627. .test-button {
  628. display: flex;
  629. flex-wrap: wrap;
  630. }
  631. .btn {
  632. display: inline-block;
  633. line-height: 1;
  634. white-space: nowrap;
  635. cursor: pointer;
  636. background: #fff;
  637. border: 1px solid #c0ccda;
  638. color: #1f2d3d;
  639. text-align: center;
  640. box-sizing: border-box;
  641. outline: none;
  642. margin: 20px 10px 0px 0px;
  643. padding: 9px 15px;
  644. font-size: 14px;
  645. border-radius: 4px;
  646. color: #fff;
  647. background-color: #50bfff;
  648. border-color: #50bfff;
  649. transition: all 0.2s ease;
  650. text-decoration: none;
  651. user-select: none;
  652. }
  653. .des {
  654. line-height: 30px;
  655. }
  656. code.language-html {
  657. padding: 10px 20px;
  658. margin: 10px 0px;
  659. display: block;
  660. background-color: #333;
  661. color: #fff;
  662. overflow-x: auto;
  663. font-family: Consolas, Monaco, Droid, Sans, Mono, Source, Code, Pro, Menlo,
  664. Lucida, Sans, Type, Writer, Ubuntu, Mono;
  665. border-radius: 5px;
  666. white-space: pre;
  667. }
  668. .show-info {
  669. margin-bottom: 50px;
  670. }
  671. .show-info h2 {
  672. line-height: 50px;
  673. }
  674. /*.title, .title:hover, .title-focus, .title:visited {
  675. color: black;
  676. }*/
  677. .title {
  678. display: block;
  679. text-decoration: none;
  680. text-align: center;
  681. line-height: 1.5;
  682. margin: 20px 0px;
  683. background-image: -webkit-linear-gradient(
  684. left,
  685. #3498db,
  686. #f47920 10%,
  687. #d71345 20%,
  688. #f7acbc 30%,
  689. #ffd400 40%,
  690. #3498db 50%,
  691. #f47920 60%,
  692. #d71345 70%,
  693. #f7acbc 80%,
  694. #ffd400 90%,
  695. #3498db
  696. );
  697. color: transparent;
  698. -webkit-background-clip: text;
  699. background-size: 200% 100%;
  700. animation: slide 5s infinite linear;
  701. font-size: 40px;
  702. }
  703. .test {
  704. height: 500px;
  705. }
  706. .model {
  707. position: fixed;
  708. z-index: 10;
  709. width: 100vw;
  710. height: 100vh;
  711. overflow: auto;
  712. top: 0;
  713. left: 0;
  714. background: rgba(0, 0, 0, 0.8);
  715. }
  716. .model-show {
  717. display: flex;
  718. justify-content: center;
  719. align-items: center;
  720. width: 100vw;
  721. height: 100vh;
  722. text-align: center;
  723. }
  724. .model img {
  725. display: block;
  726. margin: auto;
  727. max-width: 80%;
  728. width: auto;
  729. user-select: none;
  730. background-position: 0px 0px, 10px 10px;
  731. background-size: 20px 20px;
  732. background-image: linear-gradient(
  733. 45deg,
  734. #eee 25%,
  735. transparent 25%,
  736. transparent 75%,
  737. #eee 75%,
  738. #eee 100%
  739. ),
  740. linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
  741. }
  742. .c-item {
  743. display: block;
  744. padding: 10px 0;
  745. user-select: none;
  746. }
  747. .pre {
  748. display: flex;
  749. flex-wrap: wrap;
  750. }
  751. .pre-item {
  752. padding-right: 20px;
  753. }
  754. @keyframes slide {
  755. 0% {
  756. background-position: 0 0;
  757. }
  758. 100% {
  759. background-position: -100% 0;
  760. }
  761. }
  762. @media screen and (max-width: 1000px) {
  763. .content {
  764. max-width: 90%;
  765. margin: auto;
  766. }
  767. .test {
  768. height: 400px;
  769. }
  770. }
  771. </style>