The ios browser environment is unable to retrieve the value during vuejs development

When using vuejs components to create a countdown component, everything seems normal in the pc and Android environments. However, in the iOS environment, there seems to be an issue with obtaining the real count calculation as it returns NaN.

    <template>
<div class="coutpage">
<div class="countheader">

</div>
  <ul class="countdowmlist" v-if="!countdowndata.over">
    <li v-text="countdowndata.days"></li>
    <li>Days</li>
    <li v-text="countdowndata.hours"></li>
    <li>Hours</li>
    <li v-text="countdowndata.minus"></li>
    <li>Minutes</li>
    <li v-text="countdowndata.second"></li>
    <li>Seconds</li>
  </ul>
  <div class="isover" v-if="countdowndata.over">
    Time's up
  </div>
</div>
</template>

<script type="text/ecmascript-6">
export default {
  name: 'Countdown',
  props: [ 'endDate' ],
  data () {
    return {
      countdowndata: {
        days: '0',
        hours: '0',
        minus: '0',
        second: '0',
        realcount: '0',
        over: false
      },
      interval: {}
    }
  },
  created () {
    const counttime = new Date(this.endDate).getTime() - new Date().getTime()
    if (counttime < 0) {
      clearInterval(this.interval)
      return
    }
    this.countdowndata.realcount = Math.floor(counttime / 1000)
    const _this = this
    this.interval = setInterval(function () {
      _this.getCount()
    }, 1000)
  },
  methods: {
    getCount () {
      var time = this.countdowndata.realcount
      if (time <= 0) {
        clearInterval(this.interval)
        this.countdowndata.over = true
        return
      }
      var days = Math.floor(time / 60 / 60 / 24)
      var hours = Math.floor((time - days * 60 * 60 * 24) / 60 / 60)
      var minus = Math.floor((time - days * 60 * 60 * 24 - hours * 60 * 60) / 60)
      var second = Math.floor((time - days * 60 * 60 * 24 - hours * 60 * 60 - minus * 60))
      hours = hours < 10 ? ('0' + hours) : hours
      minus = minus < 10 ? ('0' + minus) : minus
      second = second < 10 ? ('0' + second) : second
      this.countdowndata.days = days
      this.countdowndata.hours = hours
      this.countdowndata.minus = minus
      this.countdowndata.second = second
      this.countdowndata.realcount--
    }
  }

}
</script>

View screenshot on iOS

View screenshot on PC or Android

I utilized the vuejs-cli along with webpack and vue-router for this project.

Answer №1

If you need to work with dates and times, look into using moment.js. It's a helpful library for handling date and time manipulations. Check it out at https://momentjs.com

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

Webpack4 Vue The parent component applies the styling to the child component

Parent Component Setup <template> <children></children> </template> <script> import children from './children' export default { components: { children } } </script> <style lang="less"> .desc ...

Is there a way for me to retrieve the text response of a fetch request from client-side JavaScript to fastify server?

In my fastify node.js application, I am encountering an issue where I can see the text results of a promise right before it is returned to the browser's JavaScript code. However, once the promise is returned to the browser JS, all I get is an empty st ...

Manipulate database variables using Javascript

As a beginner in JavaScript, I am seeking assistance with some tasks. I have to save a simple number as a JavaScript variable into a database and display the current value on two websites (with PHP used to retrieve it on the second site). This is my curre ...

Is there a way to align a button in the center of the browser's footer?

Removing these two elements will enable the image to display properly, however, it does not stay aligned with the footer when viewed in a browser. Here is a preview of how it looks: Below is the CSS code along with the HTML: <style> body { ...

The function parseFloat in Javascript can be used to subtract two numbers, returning an integer value

Apologies for the inconvenience, but I could really use some assistance. I attempted to convert a string into a decimal and was successful, although I encountered an issue: number = document.getElementById("totalcost").innerHTML; //String that rep ...

Issues arise with the blinking of my table rows

I'm working on a page with a table where certain rows need to blink under specific conditions. This page is a partial view that I load using the setInterval function. However, I've encountered an issue where the blinking functionality goes hayw ...

Unexpected issue: Ajax success function not displaying anything in the console

My code seems to be running without any output in the console. I am attempting to verify the data in order to trigger specific actions based on whether it is correct or not. However, the if-else conditions are not functioning as expected. Below is a snip ...

What is the best way to verify a password's strength with Joi so that it includes 2 numbers, 2 special characters, 2 uppercase letters, and 2 lowercase letters?

Is there a way to achieve this using Joi? For instance: Joi.string() .required() .min(8) .max(16) .pattern(/(?=(?:.*[a-z]){2,16}).+/) .pattern(/(?=(?:.*[A-Z]){2,16}).+/) .pattern(/(?=(?:.*[0-9]){2,16}).+/) .pa ...

What is the process of sending a modified array as text to TextEdit?

As a beginner in JXA, I am currently learning how to perform simple tasks in TextEdit. I have managed to extract the paragraphs of a document and store them as an array using the following code: app = Application('TextEdit') docPars = app.docu ...

The functionality of AJAX is successful when tested on a local server, but encounters issues when deployed on a live

While the following code functions correctly on localhost, it fails to work on the live server. IMPORTANT UPDATE: There's only 1 issue remaining: Upon successful execution of this AJAX block: $(".FixedDiv").addClass("panel-danger"); setTimeout(c ...

Starting up various modules in Angular 6 using arrays

Can an array be declared and used to bootstrap multiple components in module.ts? I attempted the following: export var initialComponents = []; initialComponents.push(AppComponent); if(condition) { initialComponents.push(IchFooterComponen ...

Tips for expanding button width in 'react-native-swipeout' to enable swipe action on ListView row (React Native)

Currently, I am exploring how to implement the component found here: https://github.com/dancormier/react-native-swipeout My goal is to have the row swiped all the way. Is there a method to increase the button width so that it covers the entire width of th ...

The PDF file cannot be displayed due to the dynamic loading of the path and filename

Currently, I am working on an AngularJS and Java application. The following HTML code is utilized to open a PDF file in the browser. However, there seems to be an issue where the PDF does not open when dynamically passing the value for the data attribute. ...

What is the most efficient way to retrieve all documents from all parent collections in Firebase Firestore asynchronously?

My current challenge involves retrieving all the documents from every collection within a Firestore database structured as shown below: -users(collection) -user1 (document) -snippets(collection) -snippetdId1 (document) - ...

The PHP time search function is experiencing technical difficulties and is not functioning correctly

I'm experiencing issues with adding a time search feature to my PHP site. The date search is functioning correctly, but when attempting to incorporate the time search, it doesn't seem to be working as expected. For instance, selecting 13:00 as t ...

Basic HTML code that displays either one or two columns based on the width of the screen

My monitoring website displays dynamic rrd graphs in png format with fixed dimensions. I am looking to adjust the layout based on browser window size - showing the graphs in 1 column if the width is below a certain threshold, and in 2 columns if it exceed ...

Adjust the height of an element when an animation is initiated (Angular)

Check out the transition I've set up to smoothly slide between my views: https://plnkr.co/edit/yhhdYuAl9Kpcqw5tDx55?p=preview To ensure that both 'panels' slide together, I need to position the view absolutely. However, this causes the view ...

I'm attempting to make this script function correctly when an image is loaded

Can anyone help me figure out how to make this script function on image load instead of onclick? I came across the script on stackoverflow, but it was originally set up for onclick. I want it to work for onload or .load HTML====== <div id="contai ...

Add CSS styles to the outermost container element when the slideshow is currently in use

On my homepage, I have a carousel featuring multiple slides. However, when the third slide appears in the carousel, the positioning of the carousel buttons within the div class="rotator-controls" shifts downward due to the space taken up by the image. My o ...

What is the best way to use Jquery ScrollTo() to navigate to an element on a page using a class selector

Building on the information from this source, I have a question: How can I resolve the same issue using a class selector like $('.class')? I am encountering an error message that says Uncaught TypeError: undefined is not a function This occurs ...