小编dub*_*ons的帖子

Bootstrap 3个超大(xl)列

在Bootstrap的LESS版本中,有人可以告诉我如何添加第五个设备大小,超大(col-xl-#)?

less twitter-bootstrap twitter-bootstrap-3

35
推荐指数
2
解决办法
6万
查看次数

如何在 Vue.js 2 应用程序中模拟 onbeforeunload?

我有一个 Vue 组件,它在“脏”(例如未保存)时进行跟踪。如果用户有未保存的数据,我想在他们浏览当前表单之前警告用户。在典型的 Web 应用程序中,您可以使用onbeforeunload. 我试图在这样的安装中使用它:

mounted: function(){
  window.onbeforeunload = function() {
    return self.form_dirty ? "If you leave this page you will lose your unsaved changes." : null;
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,这在使用 Vue Router 时不起作用。它可以让您根据需要导航尽可能多的路由器链接。只要您尝试关闭窗口或导航到真实链接,它就会警告您。

有没有办法onbeforeunload在 Vue 应用程序中复制普通链接和路由器链接?

javascript vue.js vue-router vuejs2

11
推荐指数
1
解决办法
8879
查看次数

为什么动态添加到购物车中的第二个产品松散了它在Magento2中的选项

我正在使用一些自定义选项动态地将产品添加到Magento2中的购物车.每个产品都具有相同的基本产品ID,具有不同的选项.Represent Product已被正确覆盖,以便添加到购物车的所有产品是分开的.但是使用此代码,添加的第二个产品将丢失它的自定义选项:

$magento_product = $this->productRepository->get('simple-product-1');
$params = array(
    'product' => $magento_product->getId(),
    'qty'     => intval(5),
    'options' => array(
        'cr_price' => 12.0,
        'Product' => "Test P",
        'cr_XML' => '<root></root>'
    ),
);
$this->cart->addProduct($magento_product, $params);
$params = array(
    'product' => $magento_product->getId(),
    'qty'     => intval(10),
    'options' => array(
        'cr_price' => 14.0,
        'Product' => "Test P2",
        'cr_XML' => '<root></root>'
    ),
);
$this->cart->addProduct($magento_product, $params);
$this->cart->save();
Run Code Online (Sandbox Code Playgroud)

只有第一个产品在quote_item_option表中有一个条目.

任何关于为什么或如何修复的想法将不胜感激.

magento cart magento2

6
推荐指数
1
解决办法
201
查看次数

到底什么是“上下文”命名约定

我正在尝试定义何时将类命名为上下文,但我遇到了非常困难的时期。有人可以为我定义“上下文”并解释何时命名类“上下文”吗?

asp.net naming-conventions httpcontext

5
推荐指数
1
解决办法
1658
查看次数

为什么我的 Vue Router 没有路由到我的组件?

我刚刚开始使用 Vue,所以请原谅这个可能很愚蠢的问题。我试图避免使用 NPM。

我定义了一个组件(在路由之外进行了测试和工作,因此我省略了模板):

var TaxonomyComponent = Vue.component('taxonomy', {
  template: '#taxonomy-component',
  data: function(){
    return {
      taxa: {
        results: [],
        count: 0
      },
      page: 1,
      page_size: 25,
      loading: true
    };
  },
  mounted(){
    this.getData();
  },
  methods:{
    getData: function(){
      var self = this;
      self.loading = false;
      self.taxa = goGetDataElsewhere();
    }
  },
  computed: {
    max_page: function(){
      return Math.ceil(this.taxa.count / this.page_size);
    }
  },
  watch:{
    page: function(){
      this.loading = true;
      this.getData();
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

然后我定义我的路由、路由器和应用程序:

var routes = [
        {path:'/', component: TaxonomyComponent},
    ];

    const router = …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-router vue-component vuejs2

2
推荐指数
1
解决办法
2062
查看次数