Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
Sendmessage failing on custom index page of the chrome extension

I have just cloned the latest vitesse-webext project and added the following code, which is sending message correctly.

// src/options/Options.vue
<script setup lang="ts">
import { sendMessage, onMessage } from 'webext-bridge'

import { storageDemo } from '~/logic/storage'

const logIt = async() => {
  console.log('hello there')
  const dd = await sendMessage('get-current-tab', {}, 'background')
  console.log(dd)
}
</script>

It logged both console messages when Log it button is clicked.

I need to sendMessage from some custom page, so I did the following:

  • I created a new folder src/test and copied the content of src/options/* into it.
  • I added its entry in prepare.ts file.
// scripts/prepare.ts
const views = [
    'options',
    'popup',
    'background',
    'test',
  ]
  • I can open this new page from the address chrome-extension:[id-of-the-extension]/dist/test/index.html.
  • But when 'Log in' button is clicked it only logs the first message and the sendMessage call is failed.

Why its not sending message from the custom page, should I need some specific settings?

the complete code can be found at https://stackblitz.com/edit/vitejs-vite-ngk771?file=src%2Ftest%2FOptions.vue&terminal=dev

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda