renderer.js 1008 B

12345678910111213141516171819202122232425262728
  1. const _ = require('lodash')
  2. module.exports = {
  3. async init($, config) {
  4. for (let i = 1; i < 6; i++) {
  5. $(`h${i}.tabset`).each((idx, elm) => {
  6. let content = `<tabset>`
  7. let tabs = []
  8. let tabContents = []
  9. $(elm).nextUntil(_.times(i, t => `h${t + 1}`).join(', '), `h${i + 1}`).each((hidx, hd) => {
  10. tabs.push(`<li @click="switchTab(${hidx})">${$(hd).html()}</li>`)
  11. let tabContent = ''
  12. $(hd).nextUntil(_.times(i + 1, t => `h${t + 1}`).join(', ')).each((cidx, celm) => {
  13. tabContent += $.html(celm)
  14. $(celm).remove()
  15. })
  16. console.info(tabContent)
  17. tabContents.push(`<div class="tabset-panel">${tabContent}</div>`)
  18. $(hd).remove()
  19. })
  20. content += `<template v-slot:tabs>${tabs.join('')}</template>`
  21. content += `<template v-slot:content>${tabContents.join('')}</template>`
  22. content += `</tabset>`
  23. $(elm).replaceWith($(content))
  24. })
  25. }
  26. }
  27. }