Vuejs1:如何在PHP中编码Vuejs参数字符串

I'm trying to escape a single quote ' in a string to be passed as argument to a component method function call.

In my template I'm printing (using php function htmlentities with ENT_QUOTES) something like:

  <button 
  @click.prevent="test('own&#039;s')">
     Test
  </button>

But seems that the html entity breaks vuejs parsing.

Here is the fiddle demo https://jsfiddle.net/76ueL3f8/1/

How can I securely escape the argument in php?

Thanks!

in Javascript, you escape quotes with a backtick. In the end, it has to look like this:

@click.prevent="test('own\'s')">

https://secure.php.net/manual/de/function.addslashes.php

addSlashes("own's")
// should result in "own\'s"