嗨,我将Visual Studio 2017与聚合物3.0结合使用。我尝试使用Iron-ajax进行剩余呼叫。但是我遇到了错误``未捕获的语法错误:意外的字符串Iron-ajax第11行''。我在iron-ajax站点复制了相同的示例但是错误是相同的。我缺少什么?
https://www.webcomponents.org/element/@polymer/iron-ajax
> <script src="node_modules/@polymer/iron-ajax/iron-ajax.js"></script>
> <script type="module">
> import { PolymerElement, html } from './node_modules/@polymer/polymer/polymer-element.js';
> //import './node_modules/@polymer/iron-ajax/iron-ajax.js';
> class SampleElement extends PolymerElement {
> static get template() {
> return html`
> <iron-ajax
> auto
> url="http://localhost:8033/api/City/All"
> hande-as="json"
> on-response="handleResponse"
> debounce-duration="300">
> </iron-ajax>
> `;
> }
> }
>
> customElements.define('sample-element', SampleElement);
> </script>
答案 0 :(得分:0)
我试图从您的代码中查找,但找不到。也许问题出在那边。这是一个工作示例: (我只是更改了网址以获取一些数据:
/**
* Add the subscription package to the user's cart.
*
* @param int $job_id
* @param int $variation_id
* @return string
*/
function add_package_to_cart( $job_id, $variation_id ) {
$job = fcrm_get_job( $job_id );
$product_id = $job->get_linked_subscription_product_id();
$quantity = 1;
$cart_item_data = array(
'job_id' => $job_id
);
// Add to cart
$key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, array(), $cart_item_data );
// Set the free trial period
wcs_set_objects_property( WC()->cart->cart_contents[ $key ]['data'], 'subscription_trial_length', $job->get_free_trial_length() );
return $key;
}