小编Inc*_*ble的帖子

Vue.js - this.$refs.key 返回一个空数组或 undefined 而不是元素

我在 Vue 2 中有一个对话框窗口组件,它正在侦听事件tcs-show-confirm(它与显示对话框的事件相同,将show属性设置为 true - 在父组件中):

  @Prop({ default: false })
  show: boolean;

  @Prop()
  buttons: Array<TcsDialogButton>;

  mounted() {

    this.$nextTick(function () {
      TcsEventBus.$on('tcs-show-confirm', () => {
        console.log(this.$refs.tcsdialbuttons);
      });
    });
  }
Run Code Online (Sandbox Code Playgroud)

组件的 html 在这里(页脚插槽的内容不会被另一个组件的 html 替换):

  ...
  <slot name="footer">
    <div v-if="buttons && buttons.length" ref="tcsdialbuttons" v-for="(button, index) in buttons">
      <button tabindex="0" class="tcs-button tcs-dialog__button" @click="$emit('close', button.emitString)">
        {{button.text}}
      </button>              
    </div>
    <div style="clear: both;"></div>
  </slot>
  ...
Run Code Online (Sandbox Code Playgroud)

问题是 console.log(this.$refs.tcsdialbuttons) 显示一个空数组 [],长度为 0。这是为什么呢?如何访问按钮并将焦点设置在第一个上?


我还尝试将胖箭头功能更改为正常功能:

      TcsEventBus.$on('tcs-show-confirm', function() {
        console.log(this.$refs.tcsdialbuttons);
      });
Run Code Online (Sandbox Code Playgroud)

但现在它返回未定义。


我刚刚发现我不能引用组件中的任何元素,即使它在我的项目中的其他组件中工作。我不明白。。

javascript dom ref vue.js vue-component

8
推荐指数
1
解决办法
2557
查看次数

Bootstrap glyphicon-menu-hamburger没有显示

这里有明确定义的汉堡菜单引导图标:http://getbootstrap.com/components/#glyphicons-glyphs

如果我在我的html中使用它,则此图标未显示,但其他图标为:

<button class="btn btn-default" type="button">
    <span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>
</button>
Run Code Online (Sandbox Code Playgroud)

这是为什么?

css icons twitter-bootstrap glyphicons

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

3D旋转 - 透视

public class MainActivity extends Activity {

LinearLayout rotator;

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rotator = (LinearLayout) findViewById(R.id.rotator);

    ObjectAnimator rotation = ObjectAnimator.ofFloat(rotator, "rotationY", 0, 360);
    rotation.setDuration(3000);
    rotation.start();

}
}
Run Code Online (Sandbox Code Playgroud)

我有上面的代码,它围绕Y轴旋转View.问题是,透视图似乎太"强烈" - 前景中的视图边缘变得太大而背景中的边缘变得太小.是否有可能"降低"透视因素?

3d animation android rotation perspective

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

Laravel - 如何获取文件的路径名

在Laravel我在我的控制器中使用此代码从目录中获取文件:

public function galleryImages($album) {

    $images = File::allFiles('gallery/'.$album);
    return View::make('galleryimages', ['images' => $images]);
}
Run Code Online (Sandbox Code Playgroud)

在我的'galleryimages'视图中是:

    @foreach($images as $image)

        <img src="???">  <-- how to get file url here?

    @endforeach
Run Code Online (Sandbox Code Playgroud)

现在我如何获得$ image变量的p​​athName?$ image的var_dump正在返回:

object(Symfony\Component\Finder\SplFileInfo)#247 (4) {
["relativePath":"Symfony\Component\Finder\SplFileInfo":private]=> string(0) "" 
["relativePathname":"Symfony\Component\Finder\SplFileInfo":private]=> string(11) "garden5.jpg" 
["pathName":"SplFileInfo":private]=> string(25) "gallery/Album/garden5.jpg" 
["fileName":"SplFileInfo":private]=> string(11) "garden5.jpg" } 
Run Code Online (Sandbox Code Playgroud)

我正在尝试$ image-> pathName,但它不起作用.

php file filepath pathname laravel

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

XAMPP-如何在htdocs中设置网站的根文件夹?

我安装了XAMPP并创建了一个包含链接的简单网站(htdocs文件夹中的文件夹“ website”)<a href="/info">Info</a>

如果我localhost/website在浏览器中键入,则会得到一个默认主页。但是,如果我单击该链接,它将转到localhost/info(不存在)而不是localhost/website/info。我可以使用<a href="/website/info">,但是在更改站点名称时重构所有链接会很奇怪。

那么人们在XAMPP中开发网站时通常使用的设置或解决方案是什么?

xampp redirect localhost root

3
推荐指数
1
解决办法
9359
查看次数

根据条件添加类(对于带有v-for的最后渲染元素)

我正在Vue.js中创建一个表并使用该v-for指令呈现一些列:

<td v-for="(item, index) in items"> {{ item.name }} </td>
Run Code Online (Sandbox Code Playgroud)

有一个未知的元素计数,我必须在最后一个渲染元素中添加一个类.我不能使用:last-child:last-of-type因为它不是<td>一行中的最后一个元素,它只是最后一个渲染元素,v-for但也有以下<td>元素.

我们怎样才能在Vue.js中实现这一目标?

javascript vue.js v-for

3
推荐指数
1
解决办法
5545
查看次数

片段 - onGlobalLayout()调用两次

public class QuadPadFragment extends Fragment {

 int w = 0; int h = 0;

 public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.quadpadlayout, container, false);

    container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {  

            h = container.getMeasuredHeight();
            w = container.getMeasuredWidth();
            Log.w("QuadPad Fragment:------", "window width: " + w + "   window height: " + h );

            view.setLayoutParams(new LayoutParams(1, 1));
        }
    });

    return view;
    }
}
Run Code Online (Sandbox Code Playgroud)

我上面写的课,一切正常,但令我困惑的是为什么onGlobalLayout被调用了两次?我得到这个输出Log:

W/QuadPad Fragment:------(27180): window width: 1080   window height: 1 …
Run Code Online (Sandbox Code Playgroud)

size layout android dimension

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

Laravel - 重定向到页面并滚动到页面底部

我使用 Laravel 框架,在我的控制器中我有

return Redirect::route('home'); 
Run Code Online (Sandbox Code Playgroud)

这是重定向到主页。但我想在重定向时完成页面向下滚动以查看页脚。有href="home#footer"没有办法做到这一点?

php redirect scroll laravel

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

继承的类,将所有继承的公共方法更改为private

我想为android继承自己的UI小部件类,它是继承的LinearLayout类.

public class MyOwnClass extends LinearLayout {

    ...
    public void setSomeProperties(Object properties) { ... }
Run Code Online (Sandbox Code Playgroud)

但LinearLayout有很多公共方法,我想要在我的类中定义的唯一公共方法.如何让MyLwnClass的实例无法访问LinearLayout的所有公共方法?

myOwnClass.setSomeProperties(properties); // only this should be accesible
myOwnClass.setBackground(...); // this should'nt be accesible
Run Code Online (Sandbox Code Playgroud)

java inheritance android private class

0
推荐指数
1
解决办法
46
查看次数

无法在Vue中使用属性装饰器@Prop

我在Vue 2中有一个组件:

import Vue from 'vue';
import Component from 'vue-class-component';
import Prop from 'vue-property-decorator';

@Component({
  template: require('./template.html'),
})

export class SuklTableApprComponent extends Vue {

  @Prop() 
  type: any;

  @Prop()
  data: any;

  mounted() {}

}
Run Code Online (Sandbox Code Playgroud)

我正在按照文档中的说明进行操作,但是打字稿不会让我使用该@Prop装饰器。它抛出一个错误:

TS2349:无法调用类型缺少调用签名的表达式。类型'typeof“ / home / tomasturan / programming / sukl / reg-dis-forms-v2 / node_modules / vue-property-decorator / li ...'没有兼容的呼叫签名。

这是为什么?我有一个类似的项目,其中似乎所有配置都相同,并且可以正常工作。为什么会引发此错误?

decorator typescript vue.js vue-component vuejs2

0
推荐指数
1
解决办法
1584
查看次数

Java array []具有未知大小 - 出了什么问题?

ImageItem imageItems[] = new ImageItem[data.length()]; 

for (int i=0; i<data.length(); i++) {

        JSONObject object = data.getJSONObject(i);
        Log.e("RESPONSE INFO::::", "id:" + object.get("id").toString());

        imageItems[i].imageId     = object.get("id").toString();    //NullPointerException
        imageItems[i].imageURI    = object.get("source").toString();
        imageItems[i].thumbURI    = object.get("picture").toString();
        imageItems[i].createdTime = object.get("created_time").toString();
        imageItems[i].link        = object.get("link").toString();

}
Run Code Online (Sandbox Code Playgroud)

以上是某种无法解决的平庸问题.我仍然得到NullPointerException与评论一致.起初我认为JSONobjects有些错误,但我确信它会object.get("id").toString();返回正确的String.imageItems[]数组必定有问题.

ImageItem是一个包含很少String字段的简单类:

public class ImageItem {
    public String imageId = null;
    public String imageURI = null;
    public String thumbURI = null;
    public String createdTime = null;
    public String link = null;
}
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么想法?

编辑:我应该提到ImageItem类是另一个类AlbumGallery的内部类.现在我收到错误:没有封闭的AlbumGallery类型的实例可访问.必须使用AlbumGallery类型的封闭实例限定分配(egxnew A(),其中x是AlbumGallery的实例). …

java arrays class nullpointerexception

-1
推荐指数
1
解决办法
81
查看次数