mdtoVueroot.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //插入 默认的 script 标签
  2. let jsroot= `<script>export default {
  3. data(){
  4. return {
  5. content:'',
  6. codeurl:'',
  7. demourl:''
  8. }
  9. },
  10. methods:{
  11. closelayer(){
  12. this.content = '';
  13. },
  14. toast(e){
  15. const options = {
  16. noHeader:true,
  17. noFooter:true,
  18. content:e.target.parentElement.outerHTML
  19. }
  20. this.content = options.content;
  21. let copy = this.copy;
  22. new copy('.copy',{
  23. target:res => {
  24. return res.previousElementSibling
  25. }
  26. });
  27. },
  28. dsCode(e){
  29. let tag = e.target;
  30. if(tag.attributes.toast){
  31. this.toast(e)
  32. }
  33. }
  34. },
  35. mounted(){
  36. //let that = this;
  37. //let pre = document.querySelectorAll('pre');
  38. // for(let i=0,item;item = pre[i];i++){
  39. // item.classList.toggle('prettyprint');
  40. // let creatC = document.createElement('i');
  41. // creatC.setAttribute('copy','copy');
  42. // creatC.setAttribute('data-clipboard-action','copy');
  43. // creatC.setAttribute('data-clipboard-target','code');
  44. // creatC.setAttribute('class','copy')
  45. // let creatA = document.createElement('i');
  46. // creatA.setAttribute('toast','toast');
  47. // item.appendChild(creatC);
  48. // item.appendChild(creatA);
  49. // }
  50. this.$nextTick(()=>{
  51. let copy = this.copy;
  52. new copy('.copy',{
  53. target:res => {
  54. return res.previousElementSibling
  55. }
  56. });
  57. let demourl = 'https://nutui.jd.com/demo.html#'+this.$route.path;
  58. this.demourl = demourl;
  59. this.qrcode.toDataURL(demourl,{width:170},(err,url)=>{
  60. this.codeurl = url
  61. });
  62. });
  63. }
  64. }
  65. </script>`;
  66. module.exports= jsroot ;