Vue cannot compile Window.resize

Could someone please assist me in identifying the issue with this code snippet? I copied some pure HTML from a specific website. The window resize function is showing up as incorrect syntax marked in red, but I'm not sure why. Any guidance on fixing this would be greatly appreciated since I'm still new to Vue.js. I have been studying the lifecycle of Vue, but so far, it hasn't provided much help check out the gamev2

<template>
  <div id="about">
    <div id="nav">
        <ul class="nav-atas">
        <li class="li nav-atas col-md-6"><a href="/">Home</a></li>
        <li class="li nav-atas col-md-6"><a class="active" href="/jobs">Jobs</a></li>
        </ul>
    </div>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb helo">
      <li class="breadcrumb-item"><a style="color:red" href="#">Tokodistributor Career</a></li>
      <li class="breadcrumb-item" aria-current="page">Jobs</li>
      </ol>
    </nav>
    <div class="titel">
      <h1>Find Your Dream Jobs Here at Tokodistributor</h1>
    </div>
    <div class="container">
      <div class="row">
            <form id="form-game_v2" name="form-game_v2">
              <div class="typeahead__container">
                  <div class="typeahead__field">
                      <div class="typeahead__query">
                          <input class="js-typeahead-game_v2" name="game_v2[query]" type="search" placeholder="Search" autocomplete="off">
                      </div>
                      <div class="typeahead__button">
                          <button type="submit">
                              <i class="typeahead__search-icon"></i>
                          </button>
                      </div>
                  </div>
              </div>
          </form>
          <div class="tombolsearch col-md-4">
              <button class="btn btn-danger">
              Search 
              </button>
              <button class="btn btn-success">
              View All Jobs
              </button>
          </div>
          <div class="container kerja">
           <h1>How Does Tokodistributor Work????</h1>
            <br>  
            <h4>At Tokodistributor We Serve Suppliers, Buyers, and Traders from across Indonesia</h4>
            <br>
            <img id="gambar1" src="../assets/image/howitworks.png"/>
            </div>
      </div>
  </div>
</div>
</template>
<script>
require('@/assets/v2/scss/styles.scss')
require('@/assets/v2/scss/Jobs.scss')
require('@/assets/js/cobacoba.js')
export default{
window.onresize = function(event) {
    if ($('#form-game_v2').find('> .typeahead__container.backdrop')) {
        $('#form-game_v2').find('.typeahead__list').css('max-height', $(window).height() - 200 + "px")
    }
} 
$.typeahead({
    input: '.js-typeahead-game_v2',
    minLength: 1,
    maxItem: false,
    highlight: false,
    hint: true,
    group: true,
    maxItemPerGroup: 16,
    backdrop: {
        "background-color": "#fff"
    },
    backdropOnFocus: true,
    cache: "sessionStorage",
    compression: true,
    cancelButton: false,
    template: function () {
      return '<span class="ui blue small label">{{display}}</span>';
    },
    source: {
        game: {
            href: "http://www.gamer-hub.com/game/{{id}}/{{display|slugify}}/",
            template: function (query, item) {
                return '<img src="http://cdn.gamer-hub.com/images/' + this.helper.slugify.call(this, item.display) + '.jpg">' +
                    '<span class="title">{{display}}</span>';
            },
            ajax: {
                url: "http://www.gamer-hub.com/game/list.json",
                dataType: "jsonp",
                path: "data"
            }
        },
        tag: {
            href: "http://www.gamer-hub.com/tag/{{id}}/{{display|slugify}}/",
            ajax: {
                url: "http://www.gamer-hub.com/tag/list.json",
                dataType: "jsonp",
                path: "data"
            }
        },
        category: {
            href: "http://www.gamer-hub.com/category/{{id}}/{{display|slugify}}/",
            ajax: {
                url: "http://www.gamer-hub.com/category/list.json",
                dataType: "jsonp",
                path: "data"
            }
        }
    },
    callback: {
        onShowLayout: function (node, query) {
            node.attr('placeholder', 'Search for a Game ...');
            node.closest('form').find('.typeahead__list').css('max-height', $(window).height() - 200 + "px");
        },
        onHideLayout: function (node, query) {
            node.attr('placeholder', 'Search');
        },
        onLayoutBuiltBefore: function (node, query, result, resultHtmlList) {
            resultHtmlList.find('li[data-search-group="game"]').remove();
            return resultHtmlList;
        },
        onClickAfter: function (node, a, item, event) {

            event.preventDefault();

            var r = confirm("You will be redirected to:\n" + item.href + "\n\nContinue?");
            if (r == true) {
                window.open(item.href);
            }

        }
    }
})
}
</script>

<style>

</style>

Answer №1

The problem here doesn't lie with your window.resize function. The issue actually stems from the export statement. You're specifying that you want to export an object, but you haven't provided one.

So, the solution is to move your code outside of the export block and only include what you specifically intend to make accessible elsewhere within the export statement.

For further information on exports, you can visit: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Harness the power of Vue.js by implementing plugin methods in your code

For my first attempt at building a SPA with Vue, I decided to re-use a few functions but encountered some issues. The error message "this.ExperienceToLevel is not a function" kept popping up and it left me puzzled. Furthermore, I'm contemplating if c ...

Can we create dynamic v-for variables in Vue.js?

<div class="col-3" v-for="n in 5" :key="n"> <h3>Table {{n}}</h3> <draggable class="list-group" :list="`list${n}`" group="people" @change="log"> ...

What could be causing my Nuxt/vue pages to be blocked by the robot.txt file?

This isn't a query about SEO best practices, but rather a question on correctly setting up config.js and script sections in VUE After building my site with Vue/Nuxt, which was previously easy for me with Angular, I am now encountering errors. The ma ...

What is the best way to access a component's data within its method using Vue and Typescript?

Starting a Vue.js project with TypeScript and using single file components instead of class-styled ones has been my goal. However, I have encountered a recurring issue where I get error TS2339 when trying to reference my components' data using the "th ...

Cross-Origin Resource Sharing (CORS): The preflight request response does not satisfy the access control check

I've been facing an issue with a simple POST method to my API through the browser. The request fails, but when I try the same on Postman, it works fine. The response includes a JSON string and two cookies. In an attempt to resolve this, I set the hea ...

Retrieve a targeted data value from a JSON object based on an array value

Looking at the JSON array and another array provided below. JSON OBJECT { id: 1, name: 'abc', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfbebdbc9fb8b2beb6b3f1bcb0b2">[emai ...

I am having trouble getting Vue.js to function properly within HTML when using Django. Can someone please lend me a

The code run Here is the HTML document: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Register</title> <!--javascript extensions--> <script src=' ...

Unable to detect click event in Vue devtools

My component is supposed to detect if a menu item has a submenu and toggle its visibility accordingly. However, when I click on it, nothing happens and no event is registered in the Vue devtools. Despite following the Vue docs closely and using the same sy ...

Unlock the potential of Vue custom props within the asyncData function in your nuxtjs project!

I have a special function in my project that serves as a plugin import Vue from 'vue' function duplicateText(text) { var input = document.createElement('input'); input.setAttribute('value', text); document.body.a ...

How can I create an event that is specific to only one element in Vue.js?

I am currently facing an issue with Vue events attached to looped elements. My challenge lies in displaying CRUD actions on individual items. Currently, all looped items display their own set of CRUD actions. Is there a way to make these actions unique t ...

A guide on transferring a Vue component to a custom local library

After successfully creating components using template syntax (*vue files), I decided to move common components to a library. The component from the library (common/src/component/VButton): <template> <button ... </button> </templat ...

display different vue component based on screen size

I am in search of a method to implement responsive components in Vue.js (Nuxt). I have developed this mix-in but encountering an error: export const mediaQuery = { data() { return { breakpoints: { sm: 576, md: 768, lg: ...

The ideal structure for a Vue app

As a newcomer to Vue, I've been exploring different guidelines on how to use it effectively. In one resource here, the project was structured with separate directories for assets, components, routes, services, and views within a 'src' direct ...

Tips for enabling editing on the result column by clicking the edit button

Each time I click on the Edit button, I want to be able to change the output in the column {{ test.result }} by turning it into an input element. This will allow me to update the numbers and then save them. Attached is a screenshot showing how the column ...

Vue component does not display FabricJS image

Currently, I am facing an issue where I want to manipulate images on a canvas using FabricJS inside a VueJS app. In the view component, there is a prop called background which I pass in and then use fabric.Image.fromURL() to load it onto the canvas. Howeve ...

"Looking to display an image object retrieved from AWS S3 using a signed URL in Vue.js? Here's how you

<div v-for="(data, key) in imgURL" :key="key"> <img :src= "getLink(data)" /> </div> imgURL here is an array that contains file names. methods: { async getLink(url){ let response = await PostsService.downloadURL({ i ...

Adjust the color according to the chosen route in a Vue component

I am looking to dynamically change the CSS color based on the route or a prop for a route. For example, if I navigate to the home page, I want the header to be red. If I visit the about page, I want the header to be green. I have attempted this using rout ...

Vuex - Managing dependencies within nested modules

I am facing a challenge in expressing a dependency between properties within my app's state using Vuex. Upon logging in, the user must select one of several workspaces to connect to. It is essential for the workspace to depend on the login status; ho ...

Is there a way to display the true colors of a picture thumbnail when we click on it?

In my project, I attempted to create a dynamic color change effect when clicking on one of four different pictures. The images are displayed as thumbnails, and upon clicking on a thumbnail, it becomes active with the corresponding logo color, similar to t ...

My Vue component seems to be missing in my Vue.js project

Here is the code for my header.vue component: <template> <div> <h2>this is header h2</h2> </div> </template> <script> export default { name: 'Header', data () { return { dat ...