去掉例如以下屬性:

至于為什么要去掉呢,你永遠不知道你的甲方有多**,舉個栗子:

一把辛酸淚 ~

以下是解決辦法:
- (1)安裝
npm install cheerio
- (2)引入
nuxt.config.js
import cheerio from 'cheerio'
export default {
hooks: {
'render:route': (url, result) => {
this.$ = cheerio.load(result.html,{decodeEntities: false});
this.$(`meta`).removeAttr('data-n-head');
result.html = this.$.html()
}
}
}
- (3)OK了

操作其他屬性一樣的操作,cheerio的選擇器以及語法和jQuery十分相似,
cheerio是jquery核心功能的一個快速靈活而又簡潔的實作,主要是為了用在服務器端需要對DOM進行操作的地方
讓你在服務器端和html愉快的玩耍
了解更多請點擊這里
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/203347.html
標籤:其他
上一篇:CSS定位
