Skip to content

Best practices for injecting into different DOM locations #1140

Answered by 1natsu172
Ya-hui asked this question in Q&A
Discussion options

You must be logged in to vote

@Ya-hui Best practice depends on the properties of the application. However, I personally think it is better to branch at the top level. That way, there is more flexibility when it is necessary to separate them.

import App from './index.vue'
export default defineContentScript({
  matches: ['*://re.baidu.com/', '*://www.baidu.com/'],
  async main(ctx) {
    const reUi = createIntegratedUi(ctx, {
      position: 'inline',
      append: 'after',
      anchor: '.offer-list-main',
      onMount: (container) => {
        // Point1: This way you can also inject application context
        const app = createApp(App, {mode: "re.baidu"})
        app.mount(container)
        return app
      },
      

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Ya-hui
Comment options

@Ya-hui
Comment options

@1natsu172
Comment options

Answer selected by Ya-hui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants