无法使用Javascript字符串获取必需的输出

时间:2018-04-25 07:37:11

标签: javascript

我无法按照愿望获得输出,当我更改数量时,我无法获得字符串中的更改。

我的代码如下 -

首先我声明变量如下 -

vm.xQty = 0;

vm.yQty = 0;

vm.promotionGroupForX = "";

vm.productCategoryForY = "";

我的字符串就像 -

"Using this promotion, Buy any " + vm.xQty + " products of " + vm.promotionGroupForX + " then get any \" + vm.yQty + \" product of " + vm.productCategoryForY + " free."

必需输出 -

如果我将xQty更改为2,yQty更改为3,promotionGroupForX = abc,vm.productCategoryForY = xyz。

"Using this promotion, Buy any 2 products of abc then get any 3 product of xyz free."

但我变得像 -

"Using this promotion, Buy any 0 products of    then get any 0 product of    free."

提前致谢。

2 个答案:

答案 0 :(得分:-1)

试试这个。

$teachers = App\Teachers::doesntHave('class')->get();

答案 1 :(得分:-1)

试试这个:

var vm = {};
vm.xQty = 0;
vm.yQty = 0;
vm.promotionGroupForX = "abc";
vm.productCategoryForY = "xyz";

console.log("Using this promotion, Buy any " + vm.xQty + " products of " + vm.promotionGroupForX + " then get any " + vm.yQty + " product of " + vm.productCategoryForY + " free.");

你正在逃避双引号 工作:https://blog.learningtree.com/paging-with-collection-views-part-2/