在Nuxt中使用Antv G2plot

2021-10-04 08:17:30 字數 972 閱讀 3547

經過一番測試下來,官網提供的注入vue例項的方法最適合,文件中是這樣描述的:

有時您希望在整個應用程式中使用某個函式或屬性值,此時,你需要將它們注入到vue例項(客戶端),context(伺服器端)甚至 store(vuex)。按照慣例,新增的屬性或方法名使用$作為字首。

將內容注入vue例項,避免重複引入,在vue原型上掛載注入乙個函式,所有元件內都可以訪問(不包含伺服器端)。

具體使用步驟為:

(省略nuxt配置的部分)

npm

install @antv/g2plot

yarn add npm @antv/g2plot
//plugins/g2.js

import vue from

'vue'

let g2 =

require

("@antv/g2plot"

)vue.prototype.$g2 = g2

export

default,]

,]}

"c1"

>

div>

//import  from '@antv/g2plot';

const bar =

this

.$g2.bar

const data =[,

,,,,

];const barplot =

newbar

('c1',)

;barplot.

render()

;

即可正常使用啦√

在Nuxt中使用scss語法

npm i d node sass sass loadersass基礎語法說明 注意 一定要寫上lang scss 才可以使用scss語法 在assets目錄下新增檔案 my global.scss base color red my btncss 以下兩種引入方式都可以 assets my glo...

在nuxt中使用路由重定向

我們都知道,在寫spa的時候,我們可以通過配置vue router來實現路由的重定向。官方文件 以及ts型別 的定義中給出了這一選項 inte ce routeconfig 也就是說,我們可以定義這樣乙個路由 這樣,我們在訪問 foo的時候,就會被重定向到 foo bar。這些都是老生常談了。然而,...

重溫2 在Activity中使用Menu

1 引用string.xml中的字串 1 中 r.string.hello world 2 xml中 string hello world 2 androidmanifest android label指定activity中標題欄的內容 也是應用程式的名稱。intent filter中的 標識mai...