Having trouble getting Vue.js to render properly while attempting to create a PDF using Phantom.js

I am facing an issue in my Vue.js components where the plain HTML gets rendered but all instances of Vue components appear blank. It seems like the hardcoded URL is causing this problem.

Can Phantom.js work properly with Vue.js?

var webPage = require('webpage');
var page = webPage.create();

page.viewportSize = { width: 1920, height: 1080 };
page.open("-----------", function start(status) {
    page.render('test.jpeg', {format: 'jpeg', quality: '100'});
    phantom.exit();
});

For anyone willing to help and run a test, here's a quick Vue code snippet:

<!DOCTYPE html>
<html>
    <head>
        <script src="https://cdn.jsdelivr.net/vue/latest/vue.js" charset="utf-8"></script>
        <style media="screen"> body { background-color: grey; } </style>
    </head>
    <body>
        plain text before vue
        <div id="app" v-text="title" />
        plain text after vue
        <script type="text/javascript">
            const app = new Vue({ el : '#app', data () { return { title : 'Vue Title' } } });
        </script>
    </body>
</html>

Answer №1

Verify the version of your phantomjs. Phantomjs Version 2.x should be compatible with vuejs.

It is likely that phantomjs is executing too rapidly, causing the element to not be ready when the code reaches that point. Consider using waitForElement or implementing a delay before attempting to access the element.

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

What could be causing the function to return undefined when using fetch, axios, ajax, or a promise?

When using asynchronous calls, the issue arises where the response is returned as undefined instead of the expected data. This problem can be seen in the following scenarios: Using Fetch const response = getDataWithFetch(); console.log(response); fun ...

Transferring PHP array data to JavaScript without being exposed in the source code

In the process of creating a historical database, I am currently handling over 2,000 photos that require categorization, out of which approximately 250 have already been uploaded. To efficiently store this data, I have set up a MySQL database with 26 field ...

Start together by a common word (not by individual letters)

I came across this amazing sharedStart function in a challenge. You can find it here: function sharedStart(array){ var A= array.concat().sort(), a1= A[0], a2= A[A.length-1], L= a1.length, i= 0; while(i<L && a1.charAt(i)=== a2.char ...

When using the console, I am able to access JSON items, but unfortunately they do not appear when using console.log

After converting a CSV file to JSON and adding custom headers for some mysterious reason, my data now appears like this: https://i.sstatic.net/H7Ls0.png Within my JavaScript file, I have the following line of code: console.log(jsonData.theData[0].symb ...

Assistance from ChromeDriver for clicking in situations where zoom level is not at 100%

While using chromedriver on Windows, I encountered an issue where the browser's zoom level impacted the functionality of element.click(). If the zoom level was anything other than 100%, the click command would target a different element instead of the ...

Integrate UploadFS functionality into angular2-meteor

Currently, I am in need of a file storage database and after some research, it appears that UploadFS is the most suitable option for my project. My development involves Angular2 typescript and Meteor. meteor add jalik:ufs-gridfs However, I am encounterin ...

Cannot instantiate Marker Clusterer as a constructor

I am facing an issue with implementing Marker Clusterer in my app. I have successfully installed '@google/markerclusterer' in my project and imported it as shown below. However, a puzzling error keeps popping up: core.js:4002 ERROR TypeError: _go ...

Is it possible to use a += operator with attr() and val() functions in JavaScript?

Ever since I switched to jQuery, my development process has significantly sped up. However, there is one task that has become a bit more time-consuming: appending a string to an attribute or value. For instance, if you wanted to add a letter to the value ...

What separates a typical update from using the $set operator for updating?

Standard procedure: module.exports = (_id, newInfo) => { return User.update( {_id} , newInfo); }; Alternative approach with $set operator: module.exports = (_id, newInfo) => { return User.update( {_id} , {$set: newInfo} ); }; ...

What is preventing the table from extending to the full 100% width?

Displayed above is an image showing an accordion on the left side and content within a table on the right side. I have a concern regarding the width of the content part (right side) as to why the table is not occupying 100% width while the heading at the ...

What is the process for loading an external file within an npm script?

Objective: Testing the linting process of specific components within the source code, without affecting all files. I want to streamline the linting process by running a single command that covers multiple folders specified in a configuration file: //pack ...

Guide on using Fetch API to send a request to a PHP file using the POST method

Hey everyone, I've recently started delving into the world of PHP and I encountered an issue while attempting to send a post request from my JavaScript file to my PHP file using the Fetch API. Upon making the request in my console, I received the foll ...

How can checkboxes be combined from two separate tables?

Within this interactive code example, you will find two tables containing checkboxes in each row. Upon clicking the To button, a dialog box will appear allowing you to select users or groups from a drop-down menu. The corresponding tables will then be dis ...

The error message reads: `'Icon' is not included in the export list of 'antd'`

I have recently developed a React application and I'm incorporating Ant Design (antd) into it. However, I encountered an issue in one of my project files where I am unable to use the Icon tag. It seems like this is a known problem in ANT V4. The impo ...

Clicking on the expand button will render the content inside the <p:panel>

My current frontend using JSF loads an excessive amount of data, not always necessary for the user. This data is categorized by tags and I want it to be rendered dynamically with a click on an expand panel: <p:panel header="#{myBean.someStringT ...

Sorting a 2D array in Javascript based on numerical values

I've come across a few similar posts regarding this issue, but none have provided solutions that work for my specific situation. I'm feeling lost on how to solve this problem (like Sort a 2D array by the second value) Let me explain the challeng ...

The AngularJS Controller Function

I'm working with a code snippet that includes an Angular Modular Controller containing a function inside the controller itself with a call. I'm unsure if this coding practice is allowed in JavaScript or Angular, and if it is, how does it work? Ta ...

Ways to insert a hyperlink within a div element

Consider the following HTML structure: <article id="1919"> <div class="entry-content clearfix"> <div></div> <div></div> </div> </article> &l ...

Looking for a rival on socket.io

Currently, I am working on a script utilizing socket.io with express in node.js to find an opponent. In this setup, only two players are allowed in a room. If no free rooms are available, a new one should be created automatically. The core logic of the c ...

I'm struggling to connect the output of my Button to my JavaScript function

I have been working on a new feature for my website and encountered an issue with a JavaScript function. The goal is to enable disabled input boxes when the user clicks on a "yes" button. Unfortunately, clicking the "yes" button doesn't seem to be tr ...